blob: ecee175c0bc3a70a4717982253857a3f766aedf6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/bin/sh
#
# Copyright (c) 2017 Aaron LI <aly@aaronly.me>
# MIT License
#
# A wrapper to invoke CASA to execute the supplied script.
#
# Shebang & header
# ----------------
# #!casa-script
# # -*- mode: python -*-
#
# Command line arguments
# ----------------------
# if __name__ == "__main__":
# argi = sys.argv.index("--") + 1
# argv = sys.argv[argi:]
# main(argv)
#
#
# Another more sophisticated wrapper:
# https://github.com/pkgw/pwpy - intfbin/casa-script
#
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} -- "$@"
|