diff options
-rwxr-xr-x | cppawk | 16 | ||||
-rw-r--r-- | testcases | 10 |
2 files changed, 15 insertions, 11 deletions
@@ -68,12 +68,6 @@ quote() esac } -# convert shell-quoted syntax to datum it denotes -unquote() -{ - eval printf \"%s \" "$1" -} - die() { fmt="$0: $1\n" ; shift @@ -129,20 +123,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") $(unquote "$prepro_opts") - > $tmp_file + eval '$prepro $incopt"$(dirname "$awk_file")" '"$prepro_opts -" > $tmp_file [ $prepro_only ] \ && cat $tmp_file \ - || $awk $(unquote "$awk_opts") -f $tmp_file "$@" + || eval "$awk $awk_opts -f $tmp_file" "$@" elif [ $# -gt 0 ] ; then tmp_file=$(mktemp) if [ $prepro_only ] ; then printf "%s" "$1" | $delhashbang | \ - $prepro $incopt"$(pwd)" $(unquote "$prepro_opts") - + eval '$prepro $incopt"$(pwd)"'"$prepro_opts -" else printf "%s" "$1" | $delhashbang | \ - $prepro $incopt"$(pwd)" $(unquote "$prepro_opts") - > $tmp_file + eval '$prepro $incopt"$(pwd)" '"$prepro_opts -" > $tmp_file shift - $awk $(unquote "$awk_opts") -f $tmp_file "$@" + eval "$awk $awk_opts -f $tmp_file \"\$@\"" fi else die "awk code must be specified" @@ -126,3 +126,13 @@ BEGIN { } ./cppawk -f testdir/program.cwk : 73 +-- +22: +./cppawk -v foo="abc def" 'BEGIN { print foo }' +: +abc def +-- +23: +./cppawk 'BEGIN { printf("%s:%s:%s\n", ARGC, ARGV[1], ARGV[2]) }' "ab c" "'" +: +3:ab c:' |