Heya,
maybe this test would be worth adding to check.t.
I think i do assume the correct behaviour.
Anyway, have a good time!

--steffen
diff --git a/check.t b/check.t
index 3b4132d..75d9b17 100644
--- a/check.t
+++ b/check.t
@@ -10848,3 +10848,24 @@ stdin:
 	done
 	Lb64decode $s >/dev/null
 ---
+name: interactive-shell-exit-trap
+description:
+	Check that interactive shell doesn't exit via EXIT trap on syntax error
+arguments: !-i!
+stdin:
+	trap -- EXIT
+	echo Syntax error <
+	echo 'After error 1'
+	trap 'echo Exit trap' EXIT
+	echo Syntax error <
+	echo 'After error 2'
+	trap 'echo Exit trap' EXIT
+	exit
+	echo 'After exit'
+expected-stdout:
+	After error 1
+	After error 2
+	Exit trap
+expected-stderr-pattern:
+	/^.*mksh: <stdin>\[\d+\]: syntax error: 'newline' unexpected/
+---
diff --git a/dot.mkshrc b/dot.mkshrc
index c10b8fd..07e54c7 100644
--- a/dot.mkshrc
+++ b/dot.mkshrc
@@ -397,6 +397,8 @@ function setenv {
 
 : place customisations below this line
 
+[[ -o interactive ]] && trap 'echo; echo INTERRUPT' INT
+
 for p in ~/.etc/bin ~/bin; do
 	[[ -d $p/. ]] || continue
 	[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH

Reply via email to