@@ -10,11 +10,12 @@ USAGE="bundle-script.sh [OPTIONS] input output [dependency [dependency [...]]]
1010
1111 Options:
1212 --check, -c If provided, the bundled script will be called with the given arguments to
13- check if it works (i.e. returns with exit code 0)."
13+ check if it works (i.e. returns with exit code 0).
14+ --gzip, -z Use additional gzip compression for bundled scripts"
1415
1516. " $( dirname " $BASH_SOURCE " ) /lib/parse_args.sh"
1617REQUIRED=(" input" " output" )
17- KEYWORDS=(" --check" " -c" )
18+ KEYWORDS=(" --check" " -c" " --gzip;bool " " -z;bool " )
1819set_trap 1
1920parse_args __USAGE " $USAGE " __DESCRIPTION " $DESCRIPTION " " $@ "
2021
5354 source_file=" $( basename " ${source_path} " ) "
5455 echo " ##### ${source_file} #####"
5556 echo -n " source <(echo '"
56- cat " ${source_path} " | base64 -w 0
57- echo " ' | base64 -d)"
57+ if [[ -z " ${KW_ARGS['--gzip']-" ${KW_ARGS['-z']} " } " ]]
58+ then
59+ base64 -w 0 " $source_path "
60+ else
61+ gzip -cq " $source_path " | base64 -w 0
62+ fi
63+ echo -n " ' | base64 -d"
64+ [[ -z " ${KW_ARGS['--gzip']-" ${KW_ARGS['-z']} " } " ]] || echo -n " | gunzip -cq"
65+ echo " )"
5866 echo -n " ######"
5967 for n in $( seq ${# source_file} ) ; do echo -n " #" ; done
6068 echo " ######"
@@ -74,6 +82,7 @@ done < "$input_script"
7482check_args=" ${KW_ARGS['--check']-${KW_ARGS['-c']} } "
7583if [[ -n " $check_args " ]]
7684then
85+ bash " $output_script " $check_args || true
7786 bash " $output_script " $check_args > /dev/null 2>&1 || {
7887 echo " ERROR: The bundled script doesn't seem to work ('bash \" $output_script \" $check_args ' terminated with exit code $? )!" >&2
7988 exit 2
0 commit comments