Multiline shebang: Difference between revisions

m (syntax highlighting fixup automation)
Line 330:
 
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 <code>9!:</code> preparatory bit from the previous example and you could also of course change the <code>1!:2&2</code> lines (<code>1!:2&2</code> 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|jq}}==
 
Here is an example using bash:
<pre>
#!/bin/bash
# this line is ignored by jq provided it ends with a backslash \
exec jq -nef "$0" "$@"
# jq code follows
true
</pre>
 
Notice the trailing `\` at the end of the second line.
 
Arguments can be passed in to the script, e.g. using the --arg NAME VALUE option.
 
The above script will also work with `sh` provided the quotation marks around `$@` are removed.
 
=={{header|Julia}}==
2,447

edits