Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/bin/sh Add a more thorough quoting test.
details: https://anonhg.NetBSD.org/src/rev/5fdcc584e3c5
branches: trunk
changeset: 522210:5fdcc584e3c5
user: christos <christos%NetBSD.org@localhost>
date: Tue Feb 12 20:38:42 2002 +0000
description:
Add a more thorough quoting test.
diffstat:
regress/bin/sh/test.sh | 5 -----
regress/bin/sh/varquote.sh | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 5 deletions(-)
diffs (48 lines):
diff -r db00882fb7fb -r 5fdcc584e3c5 regress/bin/sh/test.sh
--- a/regress/bin/sh/test.sh Tue Feb 12 20:38:41 2002 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-:
-
-# XXX this test suite is _way_ too short
-
-echo "${HOGE:-hoge}"
diff -r db00882fb7fb -r 5fdcc584e3c5 regress/bin/sh/varquote.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/bin/sh/varquote.sh Tue Feb 12 20:38:42 2002 +0000
@@ -0,0 +1,35 @@
+#!obj/sh
+# Variable quoting test.
+
+check() {
+ if [ "$1" != "$2" ]
+ then
+ echo "expected [$2], found [$1]" 1>&2
+ exit 1
+ fi
+}
+
+foo='${a:-foo}'
+check "$foo" '${a:-foo}'
+
+foo="${a:-foo}"
+check "$foo" "foo"
+
+foo=${a:-"'{}'"}
+check "$foo" "'{}'"
+
+foo=${a:-${b:-"'{}'"}}
+check "$foo" "'{}'"
+
+foo="${a:-"'{}'"}"
+check "$foo" "'{}'"
+
+foo="${a:-${b:-"${c:-${d:-"x}"}}y}"}}z}"
+# " z*"
+# ${a:- }
+# ${b:- }
+# " y*"
+# ${c:- }
+# ${d:- }
+# "x*"
+check "$foo" "x}y}z}"
Home |
Main Index |
Thread Index |
Old Index