diff options
author | Aaron LI <aly@aaronly.me> | 2017-07-02 20:52:37 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-07-02 20:52:37 +0800 |
commit | ece915ca68581580ed0795dd88fa6dc5691cd048 (patch) | |
tree | 6d4f78502a8d9dc45622bcac66ef216e3c349d06 /astro/casa | |
parent | aeb2d49a746b5eb1bf9e4fc1eba2d9860838ba36 (diff) | |
download | atoolbox-ece915ca68581580ed0795dd88fa6dc5691cd048.tar.bz2 |
astro/casa-script: hack to make it work as shebang of CASA scripts
Diffstat (limited to 'astro/casa')
-rwxr-xr-x | astro/casa/casa-script | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/astro/casa/casa-script b/astro/casa/casa-script index a1e8e6b..ecee175 100755 --- a/astro/casa/casa-script +++ b/astro/casa/casa-script @@ -22,11 +22,33 @@ # https://github.com/pkgw/pwpy - intfbin/casa-script # -if [ $# -eq 0 ] || [ "x$1" == "x-h" ]; then - echo "usage: $(basename $0) <script.py> [ script args ... ]" +PROG="${0##*/}" + +if [ $# -eq 0 ] || [ "x$1" = "x-h" ]; then + echo "usage: ${PROG} <script.py> [ script.py args ... ]" exit 1 fi script="$1" +script2="$2" shift + +# HACK: make this wrapper work as the *shebang* of CASA scripts +if [ ! -f "${script}" ] && [ -f "${script2}" ]; then + # This wrapper is called from the *shebang* of the CASA script + # NOTE: + # By self-testing, when this wrapper called from the *shebang*, + # `$0` is the absolute path to this wrapper, but `$1` is the + # first 3 lines (excluding the shebang line) of the calling CASA + # script, whose path is stored as `$2`. + echo "DEBUG: ${PROG} is called from shebang" >&2 + script="${script2}" + shift +fi + +echo "================= casa-script wrapper ================" +echo "script: ${script}" +echo "arguments: $@" +echo "======================================================" + casa --log2term --nologfile --nogui -c ${script} -- "$@" |