Multiline shebang: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
Line 749:
 
You can get around this by placing shell commands in a block comment after a single line shebang. So (ignoring the strange error message) the following works:
<syntaxhighlight lang="ecmascriptwren">#!/bin/bash
/*
echo "Hello from bash"
/bin/wren multiline_shebangMultiline_shebang.wren
exit
*/
Line 759:
{{out}}
<pre>
$ chmod +x multiline_shebangMultiline_shebang.wren
$ ./multiline_shebangMultiline_shebang.wren
./multiline_shebangMultiline_shebang.wren: line 2: /bin: Is a directory
Hello from bash
Hello from Wren
Line 767:
<br>
However, we don't actually need a multiline shebang to get the script name as this is always passed automatically as the second command line argument when the Wren process is spawned, the first argument being the Wren executable itself. Moreover, if a single line shebang is used, the third argument will be the shell command used to execute the script.
<syntaxhighlight lang="ecmascriptwren">#!/bin/wren multiline_shebangMultiline_shebang_2.wren
import "os" for Process
 
Line 780:
{{out}}
<pre>
$ chmod +x Multiline_shebang_2.wren
$ ./multiline_shebangMultiline_shebang_2.wren one two three
Executable : /bin/wren
Script name : multiline_shebangMultiline_shebang_2.wren
Shell command : ./multiline_shebangMultiline_shebang_2.wren
Argument 1 : one
Argument 2 : two
9,476

edits