commit bash-20090319 snapshot

This commit is contained in:
Chet Ramey
2011-12-08 20:06:56 -05:00
parent 1231ac4798
commit c302751c7b
99 changed files with 43003 additions and 25662 deletions
+4
View File
@@ -140,3 +140,7 @@ three
one
two
three
4.0
echo ${BASH_VERSION%\.*}
4.0
echo ${BASH_VERSION%\.*}
+2
View File
@@ -109,3 +109,5 @@ shopt -q -o history
echo $?
${THIS_SH} ./history1.sub
${THIS_SH} ./history2.sub
+111
View File
@@ -0,0 +1,111 @@
trap 'rm /tmp/newhistory' 0
# bad options
history -x
# cannot use -r and -w at the same time
history -r -w /dev/null
# bad option
fc -v
unset HISTFILESIZE
# all of these should result in an empty history list
history -c
history -r /dev/null
history -n /dev/null
history -c
HISTFILE=history.list
HISTCONTROL=ignoreboth
HISTIGNORE='&:history*:fc*'
HISTSIZE=32
shopt -s cmdhist
set -o history
history
fc -l
fc -nl
fc -lr
fc -nlr
history -s "echo line for history"
history
history -p '!!'
fc -nl
HISTFILE=/tmp/newhistory
history -a
echo displaying \$HISTFILE after history -a
cat $HISTFILE
history
history -w
cat $HISTFILE
history -s "echo line 2 for history"
history
history -p '!e'
history -p '!!'
# this should show up as one history entry
for x in one two three
do
:
done
history
# just a basic test. a full test suite for history expansion should be
# created
set -H
!!
!e
unset HISTSIZE
unset HISTFILE
fc -l 4
fc -l 4 8
fc -l one=two three=four 502
history 4
shopt -so history
shopt -s expand_aliases
alias r="fc -s"
echo aa ab ac
r a=x
r x=4 b=8
# this had better fail with `no command found'
r cc
unalias -a
alias
# these two blocks had better both result in the same output
echo aa
echo bb
echo cc
fc -e cat
echo aa
echo bb
echo cc
fc -e cat -1
set +o history
shopt -q -o history
echo $?
${THIS_SH} ./history1.sub
+10
View File
@@ -0,0 +1,10 @@
set -o history
HISTSIZE=256
HISTFILE=/dev/null
# these two lines should be the same
echo ${BASH_VERSION%\.*}
echo $(fc -nl -1)
echo ${BASH_VERSION%\.*}
fc -nl -1
+11
View File
@@ -63,6 +63,17 @@ after while
before false in trap2a.sub
after false in trap2a.sub
command substitution
+[6] echo 1
1
+[7] echo 2
2
+[8] echo 3
+[8] cat
+[8] false
++[8] echo trap: 8
trap: 8
+[9] echo 4
4
caught a child death
trap -- 'echo caught a child death' SIGCHLD
trap -- 'echo exiting' EXIT
+3
View File
@@ -66,6 +66,8 @@ trap '' USR2
# test ERR trap
./trap2.sub
${THIS_SH} ./trap3.sub
#
# show that setting a trap on SIGCHLD is not disastrous.
#
@@ -88,3 +90,4 @@ trap
trap - SIGCHLD
wait
+90
View File
@@ -0,0 +1,90 @@
# test the trap code
trap 'echo exiting' 0
trap 'echo aborting' 1 2 3 6 15
# make sure a user-specified subshell runs the exit trap, but does not
# inherit the exit trap from a parent shell
( trap 'echo subshell exit' 0; exit 0 )
( exit 0 )
trap
func()
{
trap 'echo ${FUNCNAME:-$0}[$LINENO] funcdebug' DEBUG
echo funcdebug line
}
trap 'echo [$LINENO] debug' DEBUG
echo debug line
trap
func
trap
trap 'echo ${FUNCNAME:-$0}[$LINENO] debug' DEBUG
func2()
{
echo func2debug line
}
declare -ft func2
func2
unset -f func2
trap '' DEBUG
trap
trap - debug
trap
trap - HUP
trap hup
trap '' INT
trap '' int
trap
# exit 0 in exit trap should set exit status
(
set -e
trap 'exit 0' EXIT
false
echo bad
)
echo $?
# hmmm...should this set the handling to SIG_IGN for children, too?
trap '' USR2
./trap1.sub
# test ERR trap
./trap2.sub
#
# show that setting a trap on SIGCHLD is not disastrous.
#
set -o monitor
trap 'echo caught a child death' SIGCHLD
sleep 7 & sleep 6 & sleep 5 &
# this will only catch the first, since there's a trap on SIGCHLD
wait
trap -p SIGCHLD
# Now reset some of the signals the shell handles specially back to
# their default values (with or without the SIG prefix)
trap - SIGINT QUIT TERM
trap
trap - SIGCHLD
wait
+9
View File
@@ -0,0 +1,9 @@
PS4='+[$LINENO] '
trap 'echo trap: $LINENO' ERR
set -x
echo 1
echo 2
echo 3 | cat | false
echo 4
+7
View File
@@ -0,0 +1,7 @@
PS4='+[$LINENO] '
trap 'echo trap: $LINENO' ERR
echo 1
echo 2
echo 3 | cat | false
echo 4