aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-09-05 14:07:14 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-09-05 14:07:14 +0200
commit18a90ec846f4c19b3309022d308065237145e7ce (patch)
tree7f0687d1cba6222092744b9be0d13dbf0bff5ee5 /shell/hush.c
parent750137ef7ce3d21511b4638d25a4fce0a811b60a (diff)
downloadbusybox-w32-18a90ec846f4c19b3309022d308065237145e7ce.tar.gz
busybox-w32-18a90ec846f4c19b3309022d308065237145e7ce.tar.bz2
busybox-w32-18a90ec846f4c19b3309022d308065237145e7ce.zip
hush: fix "set -o INVALID" affecting -e flag state
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 19b97e2a5..96a935875 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9824,9 +9824,12 @@ static int set_mode(int state, char mode, const char *o_opt)
9824 IF_HUSH_MODE_X(G_x_mode = state;) 9824 IF_HUSH_MODE_X(G_x_mode = state;)
9825 IF_HUSH_MODE_X(if (G.x_mode_fd <= 0) G.x_mode_fd = dup_CLOEXEC(2, 10);) 9825 IF_HUSH_MODE_X(if (G.x_mode_fd <= 0) G.x_mode_fd = dup_CLOEXEC(2, 10);)
9826 break; 9826 break;
9827 case 'e':
9828 G.o_opt[OPT_O_ERREXIT] = state;
9829 break;
9827 case 'o': 9830 case 'o':
9828 if (!o_opt) { 9831 if (!o_opt) {
9829 /* "set -+o" without parameter. 9832 /* "set -o" or "set +o" without parameter.
9830 * in bash, set -o produces this output: 9833 * in bash, set -o produces this output:
9831 * pipefail off 9834 * pipefail off
9832 * and set +o: 9835 * and set +o:
@@ -9847,9 +9850,7 @@ static int set_mode(int state, char mode, const char *o_opt)
9847 G.o_opt[idx] = state; 9850 G.o_opt[idx] = state;
9848 break; 9851 break;
9849 } 9852 }
9850 case 'e': 9853 /* fall through to error */
9851 G.o_opt[OPT_O_ERREXIT] = state;
9852 break;
9853 default: 9854 default:
9854 return EXIT_FAILURE; 9855 return EXIT_FAILURE;
9855 } 9856 }
@@ -10931,8 +10932,10 @@ static int FAST_FUNC builtin_set(char **argv)
10931 if (arg[0] != '+' && arg[0] != '-') 10932 if (arg[0] != '+' && arg[0] != '-')
10932 break; 10933 break;
10933 for (n = 1; arg[n]; ++n) { 10934 for (n = 1; arg[n]; ++n) {
10934 if (set_mode((arg[0] == '-'), arg[n], argv[1])) 10935 if (set_mode((arg[0] == '-'), arg[n], argv[1])) {
10935 goto error; 10936 bb_error_msg("%s: %s: invalid option", "set", arg);
10937 return EXIT_FAILURE;
10938 }
10936 if (arg[n] == 'o' && argv[1]) 10939 if (arg[n] == 'o' && argv[1])
10937 argv++; 10940 argv++;
10938 } 10941 }
@@ -10962,11 +10965,6 @@ static int FAST_FUNC builtin_set(char **argv)
10962 G.global_argc = 1 + string_array_len(pp + 1); 10965 G.global_argc = 1 + string_array_len(pp + 1);
10963 10966
10964 return EXIT_SUCCESS; 10967 return EXIT_SUCCESS;
10965
10966 /* Nothing known, so abort */
10967 error:
10968 bb_error_msg("%s: %s: invalid option", "set", arg);
10969 return EXIT_FAILURE;
10970} 10968}
10971#endif 10969#endif
10972 10970