Multiline shebang: Difference between revisions
Content added Content deleted
(Give a meaningful error message before exiting on error) |
m ({{out}}) |
||
Line 334: | Line 334: | ||
(println (cadr (file)) (opt) (opt)) |
(println (cadr (file)) (opt) (opt)) |
||
(bye)</lang> |
(bye)</lang> |
||
{{out}} |
|||
Output: |
|||
<pre>$ ./myScript |
<pre>$ ./myScript |
||
"myScript" "foo" "bar"</pre> |
"myScript" "foo" "bar"</pre> |
||
Line 350: | Line 350: | ||
}</lang> |
}</lang> |
||
{{out}} |
|||
output: |
|||
({ /* 3 elements */ |
({ /* 3 elements */ |
||
"/local/users/mbaehr/src/pike/multiline-shebang/multiline-shebang.pike", |
"/local/users/mbaehr/src/pike/multiline-shebang/multiline-shebang.pike", |
||
Line 371: | Line 371: | ||
print "Hello World"</lang> |
print "Hello World"</lang> |
||
{{out}} |
|||
Output: |
|||
<pre>$ ./myScript |
<pre>$ ./myScript |
||
Hello World</pre> |
Hello World</pre> |
||
Control structures (if/for/etc.) can't be quoted, |
Control structures (if/for/etc.) can't be quoted, |
||
but one can use the following to embed any script: |
|||
<lang Python>#!/bin/sh |
<lang Python>#!/bin/sh |
||
"true" '''\' |
"true" '''\' |
||
Line 408: | Line 409: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
One can use a single-line shebang, like <code>#!/usr/bin/env ruby</code>, |
One can use a single-line shebang, like <code>#!/usr/bin/env ruby</code>, |
||
and use Kernel#system or `backquotes` to run any extra shell commands. |
|||
A multi-line shebang is possible, but not necessary. |
|||
This script works both ways: either <code>/bin/sh script.rb</code> or <code>ruby script.rb</code> would run multiple lines of shell commands, and then start Ruby. |
This script works both ways: either <code>/bin/sh script.rb</code> or <code>ruby script.rb</code> would run multiple lines of shell commands, and then start Ruby. |
||
Line 451: | Line 454: | ||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
The [http://www.scala-lang.org/files/archive/nightly/docs-master/manual/html/scala.html scala(1)] interpreter parses a header section. |
The [http://www.scala-lang.org/files/archive/nightly/docs-master/manual/html/scala.html scala(1)] interpreter parses a header section. |
||
The scalac compiler does not. |
|||
<lang scala> |
<lang scala> |