diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-03-18 11:20:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-03-18 11:20:59 -0700 |
commit | f73a6746c99bbd32eeb534125baaf14a9d6e9f06 (patch) | |
tree | 0b11e97420cf33ff30f5e725a1d954aa36bc9752 | |
parent | c82cf3f4b6970b5fbf0e55d46ccfd8ae5e82589a (diff) | |
download | cppawk-f73a6746c99bbd32eeb534125baaf14a9d6e9f06.tar.gz cppawk-f73a6746c99bbd32eeb534125baaf14a9d6e9f06.tar.bz2 cppawk-f73a6746c99bbd32eeb534125baaf14a9d6e9f06.zip |
Rename shell_escape and syntax functions.
-rwxr-xr-x | cppawk | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -42,8 +42,8 @@ prepro_only= # functions -# convert argument into shell syntax that expands into that argument -shell_escape() +# convert argument into quoted shell syntax +quote() { case $1 in *"'"* ) @@ -68,8 +68,8 @@ shell_escape() esac } -# expand shell syntax for interpolation into command line -syntax() +# convert shell-quoted syntax to datum it denotes +unquote() { eval printf \"%s \" "$1" } @@ -90,7 +90,7 @@ while [ $# -gt 0 ] ; do prepro_only=y ;; -U* | -D* | -I* | -iquote* ) - prepro_opts="$prepro_opts $(shell_escape "$1")" + prepro_opts="$prepro_opts $(quote "$1")" ;; -f ) [ $# -gt 1 ] || die "-f requires argument" @@ -100,7 +100,7 @@ while [ $# -gt 0 ] ; do ;; -F | -v | -E | -i | -l | -L ) [ $# -gt 1 ] || die "%s requires argument" $1 - awk_opts="$awk_opts $1 $(shell_escape "$2")" + awk_opts="$awk_opts $1 $(quote "$2")" shift ;; -- ) @@ -115,7 +115,7 @@ while [ $# -gt 0 ] ; do prepro_opts="$prepro_opts -D__posix__=1" ;; -* ) - awk_opts="$awk_opts $(shell_escape "$1")" + awk_opts="$awk_opts $(quote "$1")" ;; * ) break @@ -129,20 +129,20 @@ trap 'rm -f $tmp_file' EXIT INT TERM if [ -n "$awk_file" ] ; then tmp_file=$(mktemp) $delhashbang "$awk_file" | \ - $prepro $incopt$(dirname "$awk_file") $(syntax "$prepro_opts") - > $tmp_file + $prepro $incopt$(dirname "$awk_file") $(unquote "$prepro_opts") - > $tmp_file [ $prepro_only ] \ && cat $tmp_file \ - || $awk $(syntax "$awk_opts") -f $tmp_file "$@" + || $awk $(unquote "$awk_opts") -f $tmp_file "$@" elif [ $# -gt 0 ] ; then tmp_file=$(mktemp) if [ $prepro_only ] ; then printf "%s" "$1" | $delhashbang | \ - $prepro $incopt"$(pwd)" $(syntax "$prepro_opts") - + $prepro $incopt"$(pwd)" $(unquote "$prepro_opts") - else printf "%s" "$1" | $delhashbang | \ - $prepro $incopt"$(pwd)" $(syntax "$prepro_opts") - > $tmp_file + $prepro $incopt"$(pwd)" $(unquote "$prepro_opts") - > $tmp_file shift - $awk $(syntax "$awk_opts") -f $tmp_file "$@" + $awk $(unquote "$awk_opts") -f $tmp_file "$@" fi else die "awk code must be specified" |