aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c3
-rw-r--r--shell/shell_common.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 8e0022531..d27550ba0 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9956,7 +9956,7 @@ Test that VAR is a valid variable name?
* until we get Nth result (or failure).
* (N == G.getopt_count is reset to 0 whenever OPTIND is [un]set).
*/
- optind = 0; /* reset getopt() state */
+ GETOPT_RESET();
count = 0;
n = string_array_len(argv);
do {
@@ -9971,6 +9971,7 @@ Test that VAR is a valid variable name?
/* Set OPTIND. Prevent resetting of the magic counter! */
set_local_var_from_halves("OPTIND", utoa(optind));
G.getopt_count = count; /* "next time, give me N+1'th result" */
+ GETOPT_RESET(); /* just in case */
/* Set OPTARG */
/* Always set or unset, never left as-is, even on exit/error:
diff --git a/shell/shell_common.c b/shell/shell_common.c
index 7a0799ed5..c978693f9 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -425,8 +425,8 @@ shell_builtin_ulimit(char **argv)
* ulimit 123 -c2 -l 456
*/
- /* In case getopt was already called:
- * reset the libc getopt() function, which keeps internal state.
+ /* In case getopt() was already called:
+ * reset libc getopt() internal state.
*/
GETOPT_RESET();