Native shebang: Difference between revisions

Content added Content deleted
m (added omits)
m (→‎{{header|Phix}}: added syntax colouring, marked p2js compatible(ish, the ignore part anyway))
Line 614: Line 614:
line of the main file start with #! it is ignored/skipped. The only difference between interpretation
line of the main file start with #! it is ignored/skipped. The only difference between interpretation
and compilation, apart from the executable file, is a -c flag on the command line, which I recommend
and compilation, apart from the executable file, is a -c flag on the command line, which I recommend
omitting unless it proves helpful or necessary. Example:
omitting unless it proves helpful or necessary. Example (quietly ignored by pwa/p2js, and Phix in general):
<lang Phix>#!/path/to/phix</lang>
<lang Phix>#!/path/to/phix</lang>
You can also invoke the compiler directly as follows
You can also invoke the compiler directly as follows
<lang Phix>string sourcefile = "test.exw",
<!--<lang Phix>(phixonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (system_exec)</span>
interpreter = get_interpreter(true),
<span style="color: #004080;">string</span> <span style="color: #000000;">sourcefile</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"test.exw"</span><span style="color: #0000FF;">,</span>
cmd = sprintf("%s %s",{interpreter,sourcefile})
<span style="color: #000000;">interpreter</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">get_interpreter</span><span style="color: #0000FF;">(</span><span style="color: #004600;">true</span><span style="color: #0000FF;">),</span>
integer res = system_exec(cmd)</lang>
<span style="color: #000000;">cmd</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%s %s"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">interpreter</span><span style="color: #0000FF;">,</span><span style="color: #000000;">sourcefile</span><span style="color: #0000FF;">})</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">system_exec</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cmd</span><span style="color: #0000FF;">)</span>
<!--</lang>-->
See also demo/capture_console.exw which redirects stdin/out/err while interpreting a child process.
See also demo/capture_console.exw which redirects stdin/out/err while interpreting a child process.