summaryrefslogtreecommitdiffstats
path: root/bin/sh/tests
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2014-12-14 16:26:19 +0000
committerjilles <jilles@FreeBSD.org>2014-12-14 16:26:19 +0000
commit412e06f616dd8b08c00e03d1fdcf4f8cf7e4bc0e (patch)
tree23fb567e57f826963e79f10430e2ea5fc2f2f033 /bin/sh/tests
parent03d4d627c59149ce3727e3c88655baa2fe773345 (diff)
downloadFreeBSD-src-412e06f616dd8b08c00e03d1fdcf4f8cf7e4bc0e.zip
FreeBSD-src-412e06f616dd8b08c00e03d1fdcf4f8cf7e4bc0e.tar.gz
sh: Make sure output suitable as shell input is also printable.
Commands like 'export -p', 'set' and 'trap', and tracing enabled via 'set -x' generate output suitable as shell input by adding quotes as necessary. If there are control characters other than newline or invalid UTF-8 sequences, use $'...' and \OOO to display them safely. The resulting output is not parsable by a strict POSIX.1-2008 shell but sh from FreeBSD 9.0 and newer and many other shells can parse it.
Diffstat (limited to 'bin/sh/tests')
-rw-r--r--bin/sh/tests/execution/Makefile1
-rw-r--r--bin/sh/tests/execution/set-x4.07
2 files changed, 8 insertions, 0 deletions
diff --git a/bin/sh/tests/execution/Makefile b/bin/sh/tests/execution/Makefile
index 2653d5f..638492b 100644
--- a/bin/sh/tests/execution/Makefile
+++ b/bin/sh/tests/execution/Makefile
@@ -44,6 +44,7 @@ FILES+= set-n4.0
FILES+= set-x1.0
FILES+= set-x2.0
FILES+= set-x3.0
+FILES+= set-x4.0
FILES+= shellproc1.0
FILES+= subshell1.0 subshell1.0.stdout
FILES+= subshell2.0
diff --git a/bin/sh/tests/execution/set-x4.0 b/bin/sh/tests/execution/set-x4.0
new file mode 100644
index 0000000..0904766
--- /dev/null
+++ b/bin/sh/tests/execution/set-x4.0
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+key=`printf '\r\t\001\200\300'`
+r=`{ set -x; : "$key"; } 2>&1 >/dev/null`
+case $r in
+*[![:print:]]*) echo fail; exit 3
+esac
OpenPOWER on IntegriCloud