summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-11-22 14:04:20 +0000
committerjilles <jilles@FreeBSD.org>2009-11-22 14:04:20 +0000
commit20812b17e03ee11696a188bf6ff7052d42c72df8 (patch)
tree0ba1f228ffeefae0838e106fccaf6a76f2040cce /tools
parent9b1c5e3514335e3055a2653349323a1a8a9220c0 (diff)
downloadFreeBSD-src-20812b17e03ee11696a188bf6ff7052d42c72df8.zip
FreeBSD-src-20812b17e03ee11696a188bf6ff7052d42c72df8.tar.gz
sh: Ensure the same command input file is on top after executing a builtin.
This avoids weirdness when 'fc -e vi' or the like is done and there is a syntax error in the file. Formerly an interactive shell tried to execute stuff after the syntax error and exited. This should also avoid similar issues with 'command eval' and 'command .' when 'command' is implemented properly as in NetBSD sh. Special builtins did not have this problem since errors in them cause the shell to exit or to reset various state such as the current command input file.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/builtins/fc1.027
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/fc1.0 b/tools/regression/bin/sh/builtins/fc1.0
new file mode 100644
index 0000000..54536ca
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/fc1.0
@@ -0,0 +1,27 @@
+# $FreeBSD$
+set -e
+trap 'echo Broken pipe -- test failed' pipe
+
+P=${TMPDIR:-/tmp}
+cd $P
+T=$(mktemp -d sh-test.XXXXXX)
+cd $T
+
+mkfifo input output error
+HISTFILE=/dev/null sh -i <input >output 2>error &
+{
+ # Syntax error
+ echo ')' >&3
+ # Read error message, shell will read new input now
+ read dummy <&5
+ # Execute bad command again
+ echo 'fc -e true' >&3
+ # Verify that the shell is still running
+ echo 'echo continued' >&3 || rc=3
+ echo 'exit' >&3 || rc=3
+ read line <&4 && [ "$line" = continued ] && : ${rc:=0}
+} 3>input 4<output 5<error
+
+rm input output error
+rmdir ${P}/${T}
+exit ${rc:-3}
OpenPOWER on IntegriCloud