diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2017-01-17 01:36:03 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2017-01-17 01:36:03 -0800 |
commit | 52a9e5d2a31b4a66ce51d0ff03ab709417dee6dc (patch) | |
tree | ef8216231785feaf7ee3f2d037f4240bdd115be8 /bin/sbang | |
parent | 4f8167b7ed8fe156e1f350aaa37230ab07a27895 (diff) | |
parent | 18563177775509286e5b53744ea5924bc450d9c2 (diff) | |
download | spack-0.10.0.tar.gz spack-0.10.0.tar.bz2 spack-0.10.0.tar.xz spack-0.10.0.zip |
Merge branch 'releases/v0.10.0'v0.10.0
Diffstat (limited to 'bin/sbang')
-rwxr-xr-x | bin/sbang | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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,13 +104,19 @@ 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" # Invoke any interpreter found, or raise an error if none was found. -if [ -n "$interpreter" ]; then - exec $interpreter "$@" +if [[ -n "$interpreter" ]]; then + if [[ "${interpreter##*/}" = "perl" ]]; then + exec $interpreter -x "$@" + else + exec $interpreter "$@" + fi else echo "error: sbang found no interpreter in $script" exit 1 |