aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-03-23 07:39:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-03-23 07:39:55 -0700
commit4e2856ddbea81e48bee950767fa4ac1a5ff6c453 (patch)
treec871c4ac5d9b5a8eb1c0dc78a05bfef219ce9954
parent7f9133cd98879c7d8cee249b7433973b37c52832 (diff)
downloadcppawk-4e2856ddbea81e48bee950767fa4ac1a5ff6c453.tar.gz
cppawk-4e2856ddbea81e48bee950767fa4ac1a5ff6c453.tar.bz2
cppawk-4e2856ddbea81e48bee950767fa4ac1a5ff6c453.zip
hygiene: what if $awk matches name of function?
We use the "command" command to make sure we are running an external awk and preprocessor. For instance if someone were to try "cppawk --awk=quote", that would be targetting the quote function inside cppawk and not that users Awk program that happens to be called "quote".
-rwxr-xr-xcppawk16
-rw-r--r--testcases5
2 files changed, 21 insertions, 0 deletions
diff --git a/cppawk b/cppawk
index 3a2b3c0..35cfffb 100755
--- a/cppawk
+++ b/cppawk
@@ -151,6 +151,22 @@ while [ $# -gt 0 ] ; do
shift
done
+case $awk in
+ 'command '* )
+ ;;
+ * )
+ awk="command $awk"
+ ;;
+esac
+
+case $prepro in
+ 'command '* )
+ ;;
+ * )
+ prepro="command $prepro"
+ ;;
+esac
+
trap 'rm -f $tmp_file' EXIT INT TERM
if [ -n "$awk_file" ] ; then
diff --git a/testcases b/testcases
index 3eb492d..8758398 100644
--- a/testcases
+++ b/testcases
@@ -198,3 +198,8 @@ mawk=1
./cppawk --prepro-only --awk=mawk gawk=__gawk__ | grep gawk
:
gawk=__gawk__
+--
+36:
+./cppawk --prepro=die --prepro-only x 2>&1 | grep 'not found'
+:
+./cppawk: 1: eval: die: not found