Native shebang: Difference between revisions
Content added Content deleted
m ({{out}} / Category:Programming environment operations) |
(jq) |
||
Line 335: | Line 335: | ||
Hello, world! |
Hello, world! |
||
</pre> |
</pre> |
||
=={{header|jq}}== |
|||
{{works with|jq|1.4}} |
|||
jq can be invoked on the shebang line, e.g. as |
|||
#!/usr/local/bin/jq -M -n -f |
|||
or |
|||
#!/usr/bin/env/jq -M -n -f |
|||
'''Example 1:''' |
|||
<lang sh># .echo.foo |
|||
#!/usr/bin/env/jq -M -n -r -f |
|||
"Klaatu barada nikto!"</lang> |
|||
$ ./echo.foo |
|||
Klaatu barada nikto! |
|||
Command-line parameters of a script created with a shebang line in this manner are processed as jq command-line parameters. |
|||
Thus, instead of being able to invoke the script along the lines of |
|||
$ ./echo.foo "Hello world!" # nope |
|||
one would have to introduce a named variable to hold the command-line parameter, |
|||
as illustrated in the next example: |
|||
'''Example 2:''' |
|||
<lang sh># .echo.foo |
|||
#!/usr/bin/env/jq -M -n -r -f |
|||
$x</lang> |
|||
{{out}} |
|||
<lang sh>$ ./echo.foo --arg x "Hello, world!" |
|||
Hello, world!</lang> |
|||