diff options
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r-- | shell/shell_common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index 1eca101..e5c2cef 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -22,6 +22,25 @@ const char defifsvar[] ALIGN1 = "IFS= \t\n"; const char defoptindvar[] ALIGN1 = "OPTIND=1"; +/* Compare two strings up to the first '=' or '\0'. */ +int FAST_FUNC varcmp(const char *p, const char *q) +{ + int c, d; + + while ((c = *p) == (d = *q)) { + if (c == '\0' || c == '=') + goto out; + p++; + q++; + } + if (c == '=') + c = '\0'; + if (d == '=') + d = '\0'; + out: + return c - d; +} + /* read builtin */ /* Needs to be interruptible: shell must handle traps and shell-special signals |