[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [git commit] hush: fix "set -o INVALID" affecting -e flag state
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2019-09-05 12:07:14
Message-ID: 20190905120314.EAB078B804 () busybox ! osuosl ! org
[Download RAW message or body]

commit: https://git.busybox.net/busybox/commit/?id=18a90ec846f4c19b3309022d308065237145e7ce
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 shell/hush.c | 20 +++++++++-----------
 1 file 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)
 		IF_HUSH_MODE_X(G_x_mode = state;)
 		IF_HUSH_MODE_X(if (G.x_mode_fd <= 0) G.x_mode_fd = dup_CLOEXEC(2, 10);)
 		break;
+	case 'e':
+		G.o_opt[OPT_O_ERREXIT] = state;
+		break;
 	case 'o':
 		if (!o_opt) {
-			/* "set -+o" without parameter.
+			/* "set -o" or "set +o" without parameter.
 			 * in bash, set -o produces this output:
 			 *  pipefail        off
 			 * and set +o:
@@ -9847,9 +9850,7 @@ static int set_mode(int state, char mode, const char *o_opt)
 			G.o_opt[idx] = state;
 			break;
 		}
-	case 'e':
-		G.o_opt[OPT_O_ERREXIT] = state;
-		break;
+		/* fall through to error */
 	default:
 		return EXIT_FAILURE;
 	}
@@ -10931,8 +10932,10 @@ static int FAST_FUNC builtin_set(char **argv)
 		if (arg[0] != '+' && arg[0] != '-')
 			break;
 		for (n = 1; arg[n]; ++n) {
-			if (set_mode((arg[0] == '-'), arg[n], argv[1]))
-				goto error;
+			if (set_mode((arg[0] == '-'), arg[n], argv[1])) {
+				bb_error_msg("%s: %s: invalid option", "set", arg);
+				return EXIT_FAILURE;
+			}
 			if (arg[n] == 'o' && argv[1])
 				argv++;
 		}
@@ -10962,11 +10965,6 @@ static int FAST_FUNC builtin_set(char **argv)
 	G.global_argc = 1 + string_array_len(pp + 1);
 
 	return EXIT_SUCCESS;
-
-	/* Nothing known, so abort */
- error:
-	bb_error_msg("%s: %s: invalid option", "set", arg);
-	return EXIT_FAILURE;
 }
 #endif
 
_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic