summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko2009-06-14 19:42:12 +0200
committerDenys Vlasenko2009-06-14 19:42:12 +0200
commit82a6fb3ea6b49bcf1ef21ab589179ee2d6ffdc09 (patch)
treeeb8ffd6fcf3a111f5392ecb47a6ad45401ae6d82 /coreutils
parent2441060bebec2d65c9d106335223f37ec6e8ea5b (diff)
downloadbusybox-82a6fb3ea6b49bcf1ef21ab589179ee2d6ffdc09.zip
busybox-82a6fb3ea6b49bcf1ef21ab589179ee2d6ffdc09.tar.gz
ash: fix . builtin
Also, move [[ ]] comment to test.c and expand it Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/test.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index cfaf4ca..73048d3 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -19,7 +19,6 @@
* Original copyright notice states:
* "This program is in the Public Domain."
*/
-
#include "libbb.h"
#include <setjmp.h>
@@ -29,7 +28,6 @@
* This is true regardless of PREFER_APPLETS and STANDALONE_SHELL
* state. */
-
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
aexpr ::= nexpr | nexpr "-a" aexpr ;
@@ -47,6 +45,50 @@
operand ::= <any legal UNIX file name>
*/
+/* TODO: handle [[ expr ]] bashism bash-compatibly.
+ * [[ ]] is meant to be a "better [ ]", with less weird syntax
+ * and without the risk of variables and quoted strings misinterpreted
+ * as operators.
+ * This will require support from shells - we need to know quote status
+ * of each parameter (see below).
+ *
+ * Word splitting and pathname expansion should NOT be performed:
+ * # a="a b"; [[ $a = "a b" ]] && echo YES
+ * YES
+ * # [[ /bin/m* ]] && echo YES
+ * YES
+ *
+ * =~ should do regexp match
+ * = and == should do pattern match against right side:
+ * # [[ *a* == bab ]] && echo YES
+ * # [[ bab == *a* ]] && echo YES
+ * YES
+ * != does the negated == (i.e., also with pattern matching).
+ * Pattern matching is quotation-sensitive:
+ * # [[ bab == "b"a* ]] && echo YES
+ * YES
+ * # [[ bab == b"a*" ]] && echo YES
+ *
+ * Conditional operators such as -f must be unquoted literals to be recognized:
+ * # [[ -e /bin ]] && echo YES
+ * YES
+ * # [[ '-e' /bin ]] && echo YES
+ * bash: conditional binary operator expected...
+ * # A='-e'; [[ $A /bin ]] && echo YES
+ * bash: conditional binary operator expected...
+ *
+ * || and && should work as -o and -a work in [ ]
+ * -a and -o aren't recognized (&& and || are to be used instead)
+ * ( and ) do not need to be quoted unlike in [ ]:
+ * # [[ ( abc ) && '' ]] && echo YES
+ * # [[ ( abc ) || '' ]] && echo YES
+ * YES
+ * # [[ ( abc ) -o '' ]] && echo YES
+ * bash: syntax error in conditional expression...
+ *
+ * Apart from the above, [[ expr ]] should work as [ expr ]
+ */
+
#define TEST_DEBUG 0
enum token {