summaryrefslogtreecommitdiffstats
path: root/bin/test/TEST.sh
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-05-26 22:33:10 +0000
committerjilles <jilles@FreeBSD.org>2009-05-26 22:33:10 +0000
commitf8b28486a955d6d96d6bb28e0c908a897cf83d1e (patch)
tree7c67338800c6dadeb3d4619c1f14c22373d35a24 /bin/test/TEST.sh
parentc1143c05d4831dacf62ba759cf7b9fa4fbdca19d (diff)
downloadFreeBSD-src-f8b28486a955d6d96d6bb28e0c908a897cf83d1e.zip
FreeBSD-src-f8b28486a955d6d96d6bb28e0c908a897cf83d1e.tar.gz
Fix various cases with 3 or 4 parameters in test(1) to be POSIX compliant.
More precisely, this gives precedence to an interpretation not using the '(', ')', '-a' and '-o' in their special meaning, if possible. For example, it is now safe to write [ "$a" = "$b" ] and assume it compares the two strings. The man page already says that test(1) works this way, so does not need to be changed. Interpretation of input with more parameters tries a bit harder to find a valid parse in some cases. Add various additional test cases to TEST.sh. PR: standards/133369 Approved by: ed (mentor)
Diffstat (limited to 'bin/test/TEST.sh')
-rw-r--r--bin/test/TEST.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/test/TEST.sh b/bin/test/TEST.sh
index bf7f3fd..6dd16bc 100644
--- a/bin/test/TEST.sh
+++ b/bin/test/TEST.sh
@@ -133,5 +133,45 @@ t 0 '"a" -a ! ""'
t 1 '""'
t 0 '! ""'
+t 0 '!'
+t 0 '\('
+t 0 '\)'
+
+t 1 '\( = \)'
+t 0 '\( != \)'
+t 0 '\( ! \)'
+t 0 '\( \( \)'
+t 0 '\( \) \)'
+t 0 '! = !'
+t 1 '! != !'
+t 1 '-n = \)'
+t 0 '! != \)'
+t 1 '! = a'
+t 0 '! != -n'
+t 0 '! -c /etc/passwd'
+
+t 0 '! \( = \)'
+t 1 '! \( != \)'
+t 1 '! = = ='
+t 0 '! = = \)'
+t 0 '! "" -o ""'
+t 1 '! "x" -o ""'
+t 1 '! "" -o "x"'
+t 1 '! "x" -o "x"'
+t 0 '\( -f /etc/passwd \)'
+t 1 '\( ! = \)'
+t 0 '\( ! "" \)'
+t 1 '\( ! -e \)'
+
+t 0 '0 -eq 0 -a -d /'
+t 0 '-s = "" -o "" = ""'
+t 0 '"" = "" -o -s = ""'
+t 1 '-s = "" -o -s = ""'
+t 0 '-z x -o x = "#" -o x = x'
+t 1 '-z y -o y = "#" -o y = x'
+t 0 '0 -ne 0 -o ! -f /'
+t 0 '1 -ne 0 -o ! -f /etc/passwd'
+t 1 '0 -ne 0 -o ! -f /etc/passwd'
+
echo ""
echo "Syntax errors: $ERROR Failed: $FAILED"
OpenPOWER on IntegriCloud