xref: /freebsd/bin/sh/tests/builtins/fc1.0 (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 set -e
2 trap 'echo Broken pipe -- test failed' PIPE
3 
4 P=${TMPDIR:-/tmp}
5 cd $P
6 T=$(mktemp -d sh-test.XXXXXX)
7 cd $T
8 
9 mkfifo input output error
10 ENV= HISTFILE=/dev/null ${SH} +m -i <input >output 2>error &
11 {
12 	# Syntax error
13 	echo ')' >&3
14 	# Read error message, shell will read new input now
15 	read dummy <&5
16 	# Execute bad command again
17 	echo 'fc -e true' >&3
18 	# Verify that the shell is still running
19 	echo 'echo continued' >&3 || rc=3
20 	echo 'exit' >&3 || rc=3
21 	read line <&4 && [ "$line" = continued ] && : ${rc:=0}
22 } 3>input 4<output 5<error
23 
24 rm input output error
25 rmdir ${P}/${T}
26 exit ${rc:-3}
27