aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/getopt32.c11
-rw-r--r--shell/ash.c4
-rw-r--r--shell/hush.c13
-rw-r--r--shell/shell_common.c2
4 files changed, 22 insertions, 8 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index 378510063..5ab4d66f1 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -89,6 +89,12 @@ getopt32(char **argv, const char *applet_opts, ...)
89 root:x:0:0:root:/root:/bin/bash 89 root:x:0:0:root:/root:/bin/bash
90 user:x:500:500::/home/user:/bin/bash 90 user:x:500:500::/home/user:/bin/bash
91 91
92 "^" options string is "^optchars""\0""opt_complementary".
93
94 "!" If the first character in the applet_opts string is a '!',
95 report bad options, missing required options,
96 inconsistent options with all-ones return value (instead of abort.
97
92 "+" If the first character in the applet_opts string is a plus, 98 "+" If the first character in the applet_opts string is a plus,
93 then option processing will stop as soon as a non-option is 99 then option processing will stop as soon as a non-option is
94 encountered in the argv array. Useful for applets like env 100 encountered in the argv array. Useful for applets like env
@@ -96,10 +102,7 @@ getopt32(char **argv, const char *applet_opts, ...)
96 env -i ls -d / 102 env -i ls -d /
97 Here we want env to process just the '-i', not the '-d'. 103 Here we want env to process just the '-i', not the '-d'.
98 104
99 "!" Report bad options, missing required options, 105 (The order of multiple prefixes must be "^!+...")
100 inconsistent options with all-ones return value (instead of abort).
101
102 "^" options string is "^optchars""\0""opt_complementary".
103 106
104uint32_t 107uint32_t
105getopt32long(char **argv, const char *applet_opts, const char *logopts...) 108getopt32long(char **argv, const char *applet_opts, const char *logopts...)
diff --git a/shell/ash.c b/shell/ash.c
index 05c47950f..bcf7a3470 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14161,6 +14161,10 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
14161 } 14161 }
14162 } 14162 }
14163 14163
14164 if (!ENABLE_ASH_BASH_COMPAT && !argptr) {
14165 bb_simple_error_msg("read: need variable name");
14166 return 1;
14167 }
14164 params.argv = argptr; 14168 params.argv = argptr;
14165 params.setvar = setvar0; 14169 params.setvar = setvar0;
14166 params.ifs = bltinlookup("IFS"); /* can be NULL */ 14170 params.ifs = bltinlookup("IFS"); /* can be NULL */
diff --git a/shell/hush.c b/shell/hush.c
index 144ad3edd..77921e11c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4251,7 +4251,7 @@ static int done_word(struct parse_context *ctx)
4251 || endofname(command->argv[0])[0] != '\0' 4251 || endofname(command->argv[0])[0] != '\0'
4252 ) { 4252 ) {
4253 /* bash says just "not a valid identifier" */ 4253 /* bash says just "not a valid identifier" */
4254 syntax_error("not a valid identifier in for"); 4254 syntax_error("bad variable name in for");
4255 return 1; 4255 return 1;
4256 } 4256 }
4257 /* Force FOR to have just one word (variable name) */ 4257 /* Force FOR to have just one word (variable name) */
@@ -10799,10 +10799,17 @@ static int FAST_FUNC builtin_read(char **argv)
10799 */ 10799 */
10800 params.read_flags = getopt32(argv, 10800 params.read_flags = getopt32(argv,
10801# if BASH_READ_D 10801# if BASH_READ_D
10802 "!srn:p:t:u:d:", &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u, &params.opt_d 10802 IF_NOT_HUSH_BASH_COMPAT("^")
10803 "!srn:p:t:u:d:" IF_NOT_HUSH_BASH_COMPAT("\0" "-1"/*min 1 arg*/),
10804 &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u, &params.opt_d
10803# else 10805# else
10804 "!srn:p:t:u:", &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u 10806 IF_NOT_HUSH_BASH_COMPAT("^")
10807 "!srn:p:t:u:" IF_NOT_HUSH_BASH_COMPAT("\0" "-1"/*min 1 arg*/),
10808 &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u
10805# endif 10809# endif
10810//TODO: print "read: need variable name"
10811//for the case of !BASH "read" with no args (now it fails silently)
10812//(or maybe extend getopt32() to emit a message if "-1" fails)
10806 ); 10813 );
10807 if ((uint32_t)params.read_flags == (uint32_t)-1) 10814 if ((uint32_t)params.read_flags == (uint32_t)-1)
10808 return EXIT_FAILURE; 10815 return EXIT_FAILURE;
diff --git a/shell/shell_common.c b/shell/shell_common.c
index e3d6783b5..2e36d9208 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -59,7 +59,7 @@ shell_builtin_read(struct builtin_read_params *params)
59 while (*pp) { 59 while (*pp) {
60 if (endofname(*pp)[0] != '\0') { 60 if (endofname(*pp)[0] != '\0') {
61 /* Mimic bash message */ 61 /* Mimic bash message */
62 bb_error_msg("read: '%s': not a valid identifier", *pp); 62 bb_error_msg("read: '%s': bad variable name", *pp);
63 return (const char *)(uintptr_t)1; 63 return (const char *)(uintptr_t)1;
64 } 64 }
65 pp++; 65 pp++;