@@ -11,11 +11,12 @@ USAGE="bundle-script.sh [OPTIONS] input output [dependency [dependency [...]]]
1111 Options:
1212 --check, -c If provided, the bundled script will be called with the given arguments to
1313 check if it works (i.e. returns with exit code 0).
14- --gzip, -z Use additional gzip compression for bundled scripts"
14+ --gzip, -z Use additional gzip compression for bundled scripts
15+ --exit, -e The expected exit code if the script is working (requires --check)"
1516
1617. " $( dirname " $BASH_SOURCE " ) /lib/parse_args.sh"
1718REQUIRED=(" input" " output" )
18- KEYWORDS=(" --check" " -c" " --gzip;bool" " -z;bool" )
19+ KEYWORDS=(" --check" " -c" " --exit " " -e " " -- gzip;bool" " -z;bool" )
1920set_trap 1
2021parse_args __USAGE " $USAGE " __DESCRIPTION " $DESCRIPTION " " $@ "
2122
@@ -82,10 +83,15 @@ done < "$input_script"
8283check_args=" ${KW_ARGS['--check']-${KW_ARGS['-c']} } "
8384if [[ -n " $check_args " ]]
8485then
85- bash " $output_script " $check_args || true
86- bash " $output_script " $check_args > /dev/null 2>&1 || {
86+ rc=0
87+ expected=" ${KW_ARGS['-e']:- 0} "
88+ expected=" ${KW_ARGS['--exit']-$expected } "
89+
90+ bash " $output_script " $check_args > /dev/null 2>&1 || rc=$?
91+ if [[ $rc -ne $expected ]]
92+ then
8793 echo " ERROR: The bundled script doesn't seem to work ('bash \" $output_script \" $check_args ' terminated with exit code $? )!" >&2
8894 exit 2
89- }
95+ fi
9096fi
9197
0 commit comments