Multiline shebang: Difference between revisions
Content added Content deleted
m (→{{header|zkl}}: tweak) |
m (→{{header|J}}) |
||
Line 203: | Line 203: | ||
<lang J>#!/bin/sh |
<lang J>#!/bin/sh |
||
# 0 :0 |
# 0 :0 |
||
echo unix shell commands go here |
echo unix shell commands go here |
||
echo presumably this will condition the environment |
echo presumably this will condition the environment |
||
echo for example: |
echo for example: |
||
cd working-directory |
cd working-directory |
||
echo or maybe you want to modify $PATH, ... whatever... |
echo or maybe you want to modify $PATH, ... whatever... |
||
echo then start up J: |
echo then start up J: |
||
exec jconsole "$0" "$@" |
exec jconsole "$0" "$@" |
||
) |
) |
||
Line 247: | Line 247: | ||
<lang J>#!/bin/sh |
<lang J>#!/bin/sh |
||
# 0 :0 |
# 0 :0 |
||
echo unix shell commands go here |
echo unix shell commands go here |
||
echo presumably this will condition the environment |
echo presumably this will condition the environment |
||
echo for example: |
echo for example: |
||
cd working-directory |
cd working-directory |
||
echo or maybe you want to modify $PATH, ... whatever... |
echo or maybe you want to modify $PATH, ... whatever... |
||
echo then start up J: |
echo then start up J: |
||
if jconsole -jprofile "$0" "$@"; then |
if jconsole -jprofile "$0" "$@"; then |
||
echo success |
echo success |
||
else |
else |
||
echo failure |
echo failure |
||
fi |
fi |
||
exit $? |
exit $? |
||
) |
) |
||
Line 273: | Line 273: | ||
The exit $? line tells the shell interpreter to ignore the J part of the file, and the $? reuses J's exit code as the exit code from the shell instance. |
The exit $? line tells the shell interpreter to ignore the J part of the file, and the $? reuses J's exit code as the exit code from the shell instance. |
||
Note that we've left off the onfail handler within J, and just used a minimal definition to give us a non-zero exit code for the error case. Mostly, the assumption here would be that the error message would not be interesting, and that any failure should be handled by a retry. But you could replace the exit on error line here with the full definition and 9!: preparatory bit from the previous example and you could also of course change the 1!:2&2 lines (1!:2&2 is the "low-level" write to stdout mechanism for J - and, yes, those numbers are part of the definition of the language - or at least the "Foreigns" part of the language - note that ultimately all computer languages resolve to things which can be thought of as numbers or sequences of numbers, though some people will vigorously assert other things). |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |