jconsole -js a=.23 b=.3 "echo a*b*c" "exit''" exits successfully for me - that last echo a*b*c thing, with undefined c is a verb which does not get evaluated, so it's ignored. But here's an example which fails to exit:
jconsole -js "a=.1 2 3" "b=.4 5" "echo a*b" "exit''" Anyways, I think you want to use the "Immex Phrase" (and flag) mentioned at http://www.jsoftware.com/help/dictionary/dx009.htm For example: jconsole -js "9!:27'exit 1'" "9!:29]1" a=.23 b=.3 "echo a*b" Note that some shells may have a problem with a ! in the command line. If that happens, it's up to you to figure out how to deal with it. For example, bash when used interactively treats ! as a backreference to a previous command line, unless you've told it not to (through set +H). (You might also set up a cover script, that adds the parts that you always use - which could include the !: bits). If you want to be able to have the command line tell whether your code completed successfully or not, you can add an exit statement at the end: jconsole -js "9!:27'exit 1'" "9!:29]1" a=.23 b=.3 "echo a*b*c" "exit 0" will have an exit code of 0 (traditionally, zero exit codes represent successful execution) and jconsole -js "9!:27'exit 1'" "9!:29]1" a=.23 b=.3 "echo 2 3*4 5 6" "exit 0" will have an exit code of 1 (traditionally non-zero exit codes represent unsuccessful execution - you probably knew that already but some readers may not be aware of this issue). Anyways, for a unix environment (mac, cygwin, linux, ...), you might want a script something like this: #!/bin/sh exec jconsole -js "9!:27'exit 1'" "9!:29]1" "$@" "exit 0" If anyone has not worked with scripts before, make sure to remember to chmod a+x that script file so that it will have permission to run. The exec is purely for efficiency. The "$@" means that the script keeps multiple arguments as distinct arguments for jconsole (as opposed to "$*" which would run them together or something without quotes which would split them on the spaces). Thanks, -- Raul On Mon, Mar 2, 2015 at 4:40 AM, Chernin, Nadav <[email protected]> wrote: > Hi, all > I use J as script language from another language through jconsole > Like this: > jconsole -js a=.23 b=.3 "echo a*b" "exit''" > My problem is when script is wrong console application don't exit > Like in this example > > jconsole -js a=.23 b=.3 "echo a*b*c" "exit''" > What can I do? > Thanks > > Nadav Chernin > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
