diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-25 08:51:41 +0300 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-25 08:51:41 +0300 |
commit | f7d56659693c78c26b25037c7f74101a4aede381 (patch) | |
tree | 3f7c11d5a9f61749bb64e0d71d500bab03f3fd39 /shell | |
parent | 68e5e2b1c730e6fc07cf9467fd64c1d284c6afe4 (diff) |
ash: comment about [[; code style fixes. No code changes.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c index 62380b3ab..9024d783d 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -2230,7 +2230,8 @@ padvance(const char **path, const char *name) if (*path == NULL) return NULL; start = *path; - for (p = start; *p && *p != ':' && *p != '%'; p++); + for (p = start; *p && *p != ':' && *p != '%'; p++) + continue; len = p - start + strlen(name) + 2; /* "2" is for '/' and '\0' */ while (stackblocksize() < len) growstackblock(); @@ -2244,7 +2245,8 @@ padvance(const char **path, const char *name) pathopt = NULL; if (*p == '%') { pathopt = ++p; - while (*p && *p != ':') p++; + while (*p && *p != ':') + p++; } if (*p == ':') *path = p + 1; @@ -8427,7 +8429,7 @@ static int exportcmd(int, char **); static int getoptscmd(int, char **); #endif #if !ENABLE_FEATURE_SH_EXTRA_QUIET -static int helpcmd(int argc, char **argv); +static int helpcmd(int, char **); #endif #if ENABLE_ASH_MATH_SUPPORT static int letcmd(int, char **); @@ -8450,7 +8452,19 @@ static int ulimitcmd(int, char **); #define BUILTIN_REG_ASSG "6" #define BUILTIN_SPEC_REG_ASSG "7" -/* make sure to keep these in proper order since it is searched via bsearch() */ +/* We do not handle [[ expr ]] bashism bash-compatibly, + * we make it a synonym of [ expr ]. + * Basically, word splitting and pathname expansion should NOT be performed + * Examples: + * no word splitting: a="a b"; [[ $a = "a b" ]]; echo $? should print "0" + * no pathname expansion: [[ /bin/m* = "/bin/m*" ]]; echo $? should print "0" + * Additional operators: + * || and && should work as -o and -a + * =~ regexp match + * Apart from the above, [[ expr ]] should work as [ expr ] + */ + +/* Keep these in proper order since it is searched via bsearch() */ static const struct builtincmd builtintab[] = { { BUILTIN_SPEC_REG ".", dotcmd }, { BUILTIN_SPEC_REG ":", truecmd }, @@ -9339,7 +9353,8 @@ chkmail(void) break; if (*p == '\0') continue; - for (q = p; *q; q++); + for (q = p; *q; q++) + continue; #if DEBUG if (q[-1] != '/') abort(); @@ -9382,7 +9397,8 @@ setparam(char **argv) char **ap; int nparam; - for (nparam = 0; argv[nparam]; nparam++); + for (nparam = 0; argv[nparam]; nparam++) + continue; ap = newparam = ckmalloc((nparam + 1) * sizeof(*ap)); while (*argv) { *ap++ = ckstrdup(*argv++); @@ -9531,7 +9547,8 @@ shiftcmd(int argc ATTRIBUTE_UNUSED, char **argv) free(*ap1); } ap2 = shellparam.p; - while ((*ap2++ = *ap1++) != NULL); + while ((*ap2++ = *ap1++) != NULL) + continue; #if ENABLE_ASH_GETOPTS shellparam.optind = 1; shellparam.optoff = -1; @@ -10563,7 +10580,8 @@ checkend: { char *p, *q; p = line; - for (q = eofmark + 1; *q && *p == *q; p++, q++); + for (q = eofmark + 1; *q && *p == *q; p++, q++) + continue; if (*p == '\n' && *q == '\0') { c = PEOF; plinno++; @@ -11004,7 +11022,8 @@ xxreadtoken(void) #endif ) { if (c == '#') { - while ((c = pgetc()) != '\n' && c != PEOF); + while ((c = pgetc()) != '\n' && c != PEOF) + continue; pungetc(); } else if (c == '\\') { if (pgetc() != '\n') { @@ -11067,7 +11086,8 @@ xxreadtoken(void) #endif continue; case '#': - while ((c = pgetc()) != '\n' && c != PEOF); + while ((c = pgetc()) != '\n' && c != PEOF) + continue; pungetc(); continue; case '\\': |