summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2019-03-22 22:41:06 +0000
committerrillig <rillig@pkgsrc.org>2019-03-22 22:41:06 +0000
commit73238fc8bb2a0b2486ada5fd2542db4abe2675e1 (patch)
treed9661bff2afbaaf5f09a72bb01381f92d17d2970 /regress
parent748d43b9cb2762843fe70beb25a718aba885880f (diff)
downloadpkgsrc-73238fc8bb2a0b2486ada5fd2542db4abe2675e1.tar.gz
regress/tools: demonstrate wrong shell quoting in the tools wrapper
Diffstat (limited to 'regress')
-rw-r--r--regress/tools/Makefile17
-rwxr-xr-xregress/tools/files/logging-test.sh18
2 files changed, 33 insertions, 2 deletions
diff --git a/regress/tools/Makefile b/regress/tools/Makefile
index c8928a77719..31daf26065b 100644
--- a/regress/tools/Makefile
+++ b/regress/tools/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 2019/03/22 20:56:16 rillig Exp $
+# $NetBSD: Makefile,v 1.12 2019/03/22 22:41:06 rillig Exp $
#
DISTNAME= # not applicable
@@ -18,6 +18,21 @@ REGRESS_TESTS+= logging
REGRESS_TESTS+= awk sed sh sort tar tr
USE_TOOLS+= awk sed sh sort tar tr
+TOOLS_CREATE+= script-dquot
+TOOLS_SCRIPT.script-dquot= \
+ echo "hello; world"
+
+TOOLS_CREATE+= script-backslash
+TOOLS_SCRIPT.script-backslash= \
+ echo hello\;\ world
+
+# If both of the above tools are properly quoted during logging, the
+# semicolon in "hello; world" is never interpreted as a shell command
+# delimiter, and this tool is never run.
+TOOLS_CREATE+= world
+TOOLS_SCRIPT.world= \
+ echo oops
+
do-build:
.for t in ${REGRESS_TESTS}
${RUN} cd ${WRKSRC}; \
diff --git a/regress/tools/files/logging-test.sh b/regress/tools/files/logging-test.sh
index 3e698c0823d..3c716314b75 100755
--- a/regress/tools/files/logging-test.sh
+++ b/regress/tools/files/logging-test.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: logging-test.sh,v 1.2 2019/03/22 22:13:21 rillig Exp $
+# $NetBSD: logging-test.sh,v 1.3 2019/03/22 22:41:06 rillig Exp $
# Up to March 2019, the command logging for the wrapped tools didn't properly
# quote the command line arguments. This meant the logging did not reflect
@@ -31,6 +31,8 @@ export TOOLS_WRAPPER_LOG
(exec echo "squot" "'" "end")
(exec echo "five" '\\\\\' "end")
(exec mkdir "directory with spaces")
+(exec script-dquot)
+(exec script-backslash)
unset TOOLS_WRAPPER_LOG
@@ -63,4 +65,18 @@ assert_file_equals "$nopath_log" <<'EOF'
<.> echo five \\\\\ end
[*] WRKDIR/.tools/bin/mkdir directory with spaces
<.> BINDIR/mkdir -p directory with spaces
+[*] WRKDIR/.tools/bin/script-dquot
+[*] WRKDIR/.tools/bin/world
+<.> echo oops
+oops
+[*] WRKDIR/.tools/bin/script-backslash
+<.> echo hello\;\ world
EOF
+
+# FIXME: The tool wrapper log must contain [*] and <.> equally often.
+# Explanation:
+# In WRKDIR/.tools/bin/script-dquot, the shell quoting is obviously wrong.
+# This results in "hello" being echoed to stdout instead of the log file.
+# This also results in the "hello" tool to be run.
+# The output of that tool is appended to the log file, as can be seen in
+# the tool wrapper script.