diff options
-rwxr-xr-x | cppawk | 19 | ||||
-rw-r--r-- | testcases | 5 |
2 files changed, 19 insertions, 5 deletions
@@ -38,6 +38,7 @@ awk_file= awk_opts= tmp_file= delhashbang="sed -e /^#!/d" +prepro_only= # functions shell_escape() @@ -77,6 +78,9 @@ while [ $# -gt 0 ] ; do -M?* ) die "-M family of cpp options not supported" ;; + --prepro-only ) + prepro_only=y + ;; -U* | -D* | -I* | -iquote* ) prepro_opts="$prepro_opts $(shell_escape "$1")" ;; @@ -117,13 +121,18 @@ trap 'rm -f $tmp_file' EXIT INT TERM if [ -n "$awk_file" ] ; then tmp_file=$(mktemp) $delhashbang "$awk_file" | $prepro $prepro_opts - > $tmp_file - $awk $awk_opts -f $tmp_file "$@" + [ $prepro_only ] && cat $tmp_file || $awk $awk_opts -f $tmp_file "$@" elif [ $# -gt 0 ] ; then tmp_file=$(mktemp) - printf "%s" "$1" | $delhashbang | \ - $prepro $incopt"$(pwd)" $prepro_opts - > $tmp_file - shift - $awk $awk_opts -f $tmp_file "$@" + if [ $prepro_only ] ; then + printf "%s" "$1" | $delhashbang | \ + $prepro $incopt"$(pwd)" $prepro_opts - + else + printf "%s" "$1" | $delhashbang | \ + $prepro $incopt"$(pwd)" $prepro_opts - > $tmp_file + shift + $awk $awk_opts -f $tmp_file "$@" + fi else die "awk code must be specified" fi @@ -111,3 +111,8 @@ gawk 20: ./cppawk 'BEGIN { print __posix__ }' : +-- +21: +./cppawk --prepro-only 'BEGIN { }' | grep BEGIN +: +BEGIN { } |