diff options
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r-- | shell/shell_common.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index 657ee9969..da157ea0e 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c | |||
@@ -22,6 +22,25 @@ | |||
22 | const char defifsvar[] ALIGN1 = "IFS= \t\n"; | 22 | const char defifsvar[] ALIGN1 = "IFS= \t\n"; |
23 | const char defoptindvar[] ALIGN1 = "OPTIND=1"; | 23 | const char defoptindvar[] ALIGN1 = "OPTIND=1"; |
24 | 24 | ||
25 | /* Compare two strings up to the first '=' or '\0'. */ | ||
26 | int FAST_FUNC varcmp(const char *p, const char *q) | ||
27 | { | ||
28 | int c, d; | ||
29 | |||
30 | while ((c = *p) == (d = *q)) { | ||
31 | if (c == '\0' || c == '=') | ||
32 | goto out; | ||
33 | p++; | ||
34 | q++; | ||
35 | } | ||
36 | if (c == '=') | ||
37 | c = '\0'; | ||
38 | if (d == '=') | ||
39 | d = '\0'; | ||
40 | out: | ||
41 | return c - d; | ||
42 | } | ||
43 | |||
25 | /* read builtin */ | 44 | /* read builtin */ |
26 | 45 | ||
27 | /* Needs to be interruptible: shell must handle traps and shell-special signals | 46 | /* Needs to be interruptible: shell must handle traps and shell-special signals |
@@ -59,7 +78,7 @@ shell_builtin_read(struct builtin_read_params *params) | |||
59 | argv = params->argv; | 78 | argv = params->argv; |
60 | pp = argv; | 79 | pp = argv; |
61 | while (*pp) { | 80 | while (*pp) { |
62 | if (endofname(*pp)[0] != '\0') { | 81 | if (!*pp[0] || endofname(*pp)[0] != '\0') { |
63 | /* Mimic bash message */ | 82 | /* Mimic bash message */ |
64 | bb_error_msg("read: '%s': bad variable name", *pp); | 83 | bb_error_msg("read: '%s': bad variable name", *pp); |
65 | return (const char *)(uintptr_t)1; | 84 | return (const char *)(uintptr_t)1; |