shell: add comments about [[, no code changes
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 10 Apr 2018 13:25:41 +0000 (15:25 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 10 Apr 2018 13:25:41 +0000 (15:25 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/test.c
shell/ash.c
shell/hush.c

index 824ce3b5a06c56cf0527e83696c7b69d587d12b2..ddb66ddcec1f17aba1c43207d7aa1fb868a2708f 100644 (file)
@@ -313,6 +313,9 @@ static const struct operator_t ops_table[] = {
        { /* "-L" */ FILSYM  , UNOP   },
        { /* "-S" */ FILSOCK , UNOP   },
        { /* "="  */ STREQ   , BINOP  },
+       /* "==" is bashism, http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
+        * lists only "=" as comparison operator.
+        */
        { /* "==" */ STREQ   , BINOP  },
        { /* "!=" */ STRNE   , BINOP  },
        { /* "<"  */ STRLT   , BINOP  },
@@ -357,6 +360,7 @@ static const char ops_texts[] ALIGN1 =
        "-L"  "\0"
        "-S"  "\0"
        "="   "\0"
+       /* "==" is bashism */
        "=="  "\0"
        "!="  "\0"
        "<"   "\0"
index 45c747dbcd09bc1045f214e5241d59cc1397fa8c..713219b6e75b22c071b2bcb3c5052913f7235dd5 100644 (file)
 #define IF_BASH_PATTERN_SUBST       IF_ASH_BASH_COMPAT
 #define    BASH_SUBSTR          ENABLE_ASH_BASH_COMPAT
 #define IF_BASH_SUBSTR              IF_ASH_BASH_COMPAT
-/* [[ EXPR ]] */
+/* BASH_TEST2: [[ EXPR ]]
+ * Status of [[ support:
+ * We replace && and || with -a and -o
+ * TODO:
+ * singleword+noglob expansion:
+ *   v='a b'; [[ $v = 'a b' ]]; echo 0:$?
+ *   [[ /bin/* ]]; echo 0:$?
+ * -a/-o are not AND/OR ops! (they are just strings)
+ * quoting needs to be considered (-f is an operator, "-f" and ""-f are not; etc)
+ * = is glob match operator, not equality operator: STR = GLOB
+ * (in GLOB, quoting is significant on char-by-char basis: a*cd"*")
+ * == same as =
+ * add =~ regex match operator: STR =~ REGEX
+ */
 #define    BASH_TEST2           (ENABLE_ASH_BASH_COMPAT * ENABLE_ASH_TEST)
 #define    BASH_SOURCE          ENABLE_ASH_BASH_COMPAT
 #define    BASH_PIPEFAIL        ENABLE_ASH_BASH_COMPAT
index 98ba96e0c290f3e5c203f497a580e3b8fb853a9f..3afb70cb042882be2bac29a154ef1deeea9d397a 100644 (file)
  *      Some builtins mandated by standards:
  *          newgrp [GRP]: not a builtin in bash but a suid binary
  *              which spawns a new shell with new group ID
+ *
+ * Status of [[ support:
+ * [[ args ]] are CMD_SINGLEWORD_NOGLOB:
+ *   v='a b'; [[ $v = 'a b' ]]; echo 0:$?
+ *   [[ /bin/* ]]; echo 0:$?
+ * TODO:
+ * &&/|| are AND/OR ops, -a/-o are not
+ * quoting needs to be considered (-f is an operator, "-f" and ""-f are not; etc)
+ * = is glob match operator, not equality operator: STR = GLOB
+ * (in GLOB, quoting is significant on char-by-char basis: a*cd"*")
+ * == same as =
+ * add =~ regex match operator: STR =~ REGEX
  */
 //config:config HUSH
 //config:      bool "hush (64 kb)"