summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-06-23 00:03:23 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-06-23 00:03:23 -0700
commit27e9bc6d028e3ee8b4890c226594e25bcfc370eb (patch)
treeed6af6bba13b1ae01876c1e86393afcdc5e0f540 /bin
parent86893e3dc4a82588e18c8832c4a8811fb5e83273 (diff)
downloadspack-27e9bc6d028e3ee8b4890c226594e25bcfc370eb.tar.gz
spack-27e9bc6d028e3ee8b4890c226594e25bcfc370eb.tar.bz2
spack-27e9bc6d028e3ee8b4890c226594e25bcfc370eb.tar.xz
spack-27e9bc6d028e3ee8b4890c226594e25bcfc370eb.zip
Make sbang handle lua
- use --! instead of #! for patched lua scripts.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/sbang11
1 files changed, 11 insertions, 0 deletions
diff --git a/bin/sbang b/bin/sbang
index f6b6d35e8a..1ea5f06592 100755
--- a/bin/sbang
+++ b/bin/sbang
@@ -79,6 +79,15 @@
# Obviously, for this to work, `sbang` needs to have a short enough
# path that *it* will run without hitting OS limits.
#
+# For Lua, scripts the second line can't start with #!, as # is not
+# the comment character in lua (even though lua ignores #! on the
+# *first* line of a script). So, instrument a lua script like this,
+# using -- instead of # on the second line:
+#
+# 1 #!/bin/bash /path/to/sbang
+# 2 --!/long/path/to/lua with arguments
+# 3
+# 4 print "success!"
#
# How it works
# -----------------------------
@@ -95,6 +104,8 @@ lines=0
while read line && ((lines < 2)) ; do
if [[ "$line" = '#!'* ]]; then
interpreter="${line#\#!}"
+ elif [[ "$line" = '--!'*lua* ]]; then
+ interpreter="${line#--!}"
fi
lines=$((lines+1))
done < "$script"