7fc12bb30d0b7a92c219a603919bfb43f72e27d7 — Drew DeVault 11 months ago 8a39bf5
unspecified.c: don't abort in interactive shells
1 files changed, 10 insertions(+), 3 deletions(-)

M builtin/unspecified.c
M builtin/unspecified.c => builtin/unspecified.c +10 -3
@@ 5,7 5,14 @@
 
 int builtin_unspecified(struct mrsh_state *state, int argc, char *argv[]) {
 	// Ref: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01
-	fprintf(stderr, "%s: The behavior of this command is undefined. "
-			"This is an error in your script. Aborting.\n", argv[0]);
-	exit(1);
+	if (state->interactive) {
+		fprintf(stderr,
+				"%s: The behavior of this command is undefined.", argv[0]);
+	} else {
+		fprintf(stderr, "%s: The behavior of this command is undefined. "
+				"This is an error in your script. Aborting.\n", argv[0]);
+		state->exit = EXIT_FAILURE;
+	}
+
+	return EXIT_FAILURE;
 }