aboutsummaryrefslogtreecommitdiff
path: root/shell/shell_common.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-07-13 08:06:26 +0100
committerRon Yorston <rmy@pobox.com>2023-07-13 08:06:26 +0100
commitbd978d0256fd3a67de1a7dd54f1a37f9435be363 (patch)
treecb869384a533ac0d95fe787d75be6c050e1e7c1a /shell/shell_common.c
parentb2901ce8efa050da00e0f3a73f3be9bf9402deea (diff)
parentd70256a5c719439cc6fab6a4571c1bb46178e4c7 (diff)
downloadbusybox-w32-bd978d0256fd3a67de1a7dd54f1a37f9435be363.tar.gz
busybox-w32-bd978d0256fd3a67de1a7dd54f1a37f9435be363.tar.bz2
busybox-w32-bd978d0256fd3a67de1a7dd54f1a37f9435be363.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r--shell/shell_common.c21
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 @@
22const char defifsvar[] ALIGN1 = "IFS= \t\n"; 22const char defifsvar[] ALIGN1 = "IFS= \t\n";
23const char defoptindvar[] ALIGN1 = "OPTIND=1"; 23const char defoptindvar[] ALIGN1 = "OPTIND=1";
24 24
25/* Compare two strings up to the first '=' or '\0'. */
26int 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;