4

I have two jshell scripts script.jsh and commons.jsh in the same folder /path/folder.

script.jsh:

/open commons.jsh

commons.jsh:

System.out.println("commons.jsh loaded")
  • If I am in /path/folder, I can run jshell script.jsh and it works well
  • If I am in /path/folder/subfolder and I run jshell ../script.jsh, it fails with File 'commons.jsh' for '/open' is not found.

Is there any solution to this? In other words, can the jshell command /open work relatively to the folder containing the script, instead of the working directory?

A similar question was asked here for bash: Bash: How _best_ to include other scripts?

Edit1: making the question more precise

Edit2: here are the real jshell scripts that I was working on when writing this question, the first script available here https://framagit.org/Gwendal/helpful-scripts/blob/3e8118970a6a412dfe0f199e93545745d890243f/jshell/dia2pdf.jsh which opens this second script containing a helper method https://framagit.org/Gwendal/helpful-scripts/blob/3e8118970a6a412dfe0f199e93545745d890243f/jshell/commons.jsh

Gwendal
  • 490
  • 3
  • 13
  • Well thought over this one for a while and restricting it to this comment. IMHO, the use case boils down to the need of Interactive Shell[(!=REPL)](https://www.johndcook.com/blog/2012/06/26/shell-repl/). A prime difference of using the specific location of an X script to be executed from Y location. Not to deny the fact that such user inputs can be supported, but needs to be evaluated for a [REPL to provide that](https://softwareengineering.stackexchange.com/questions/168285/difference-between-a-repl-and-interactive-shell). Though, what might work is wrapping the `.jsh` with a `.sh` script eq. – Naman Oct 17 '17 at 07:10

1 Answers1

1

Ok i've been looking into this one for quite some time...

And the only way i know of is to just add the full path of the "commons.jsh"-file. And it works.

Jens Nedregård
  • 199
  • 1
  • 13