fc2.0 revision 211408
1200998Sjilles# $FreeBSD: head/tools/regression/bin/sh/builtins/fc2.0 211408 2010-08-16 22:23:19Z jilles $ 2200998Sjillesset -e 3211408Sjillestrap 'echo Broken pipe -- test failed' PIPE 4200998Sjilles 5200998SjillesP=${TMPDIR:-/tmp} 6200998Sjillescd $P 7200998SjillesT=$(mktemp -d sh-test.XXXXXX) 8200998Sjillescd $T 9200998Sjilles 10200998Sjillesmkfifo input output error 11200998SjillesHISTFILE=/dev/null sh +m -i <input >output 2>error & 12200998Sjillesexec 3>input 13200998Sjilles{ 14200998Sjilles # Command not found, containing slash 15200998Sjilles echo '/var/empty/nonexistent' >&3 16200998Sjilles # Read error message, shell will read new input now 17200998Sjilles read dummy <&5 18200998Sjilles # Execute bad command again 19200998Sjilles echo 'fc -e true; echo continued' >&3 20200998Sjilles read dummy <&5 21200998Sjilles read line <&4 && [ "$line" = continued ] && : ${rc:=0} 22200998Sjilles exec 3>&- 23200998Sjilles # Old sh duplicates itself after the fc, producing another line 24200998Sjilles # of output. 25200998Sjilles if read line <&4; then 26200998Sjilles echo "Extraneous output: $line" 27200998Sjilles rc=1 28200998Sjilles fi 29200998Sjilles} 4<output 5<error 30200998Sjillesexec 3>&- 31200998Sjilles 32200998Sjillesrm input output error 33200998Sjillesrmdir ${P}/${T} 34200998Sjillesexit ${rc:-3} 35