Multiline shebang: Difference between revisions

Added FreeBASIC
(Added FreeBASIC)
(One intermediate revision by one other user not shown)
Line 169:
.( hello world) CR BYE
</syntaxhighlight>
 
=={{header|FreeBASIC}}==
FreeBASIC is a compiled, uninterpreted language, so it cannot be run directly from the Unix command line with a shebang.
 
However, you can create a shell script that compiles and runs your FreeBASIC program. Here I show an example:
 
<syntaxhighlight lang="vbnet">
#!/bin/bash
# Compile the FreeBASIC program
fbc myprogram.bas
# Run the compiled program
./myprogram
</syntaxhighlight>
 
In this script, myprogram.bas is a FreeBASIC program. When you run this shell script, it will compile the FreeBASIC program and then run it.
 
=={{header|Go}}==
Line 749 ⟶ 764:
 
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 ⟶ 774:
{{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 ⟶ 782:
<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 ⟶ 795:
{{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
2,169

edits