bash-4.1 remove leftover and stray files

This commit is contained in:
Chet Ramey
2011-12-08 20:23:56 -05:00
parent 984a1947a3
commit 30715bca2d
160 changed files with 0 additions and 207219 deletions
-9
View File
@@ -1,9 +0,0 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
export THIS_SH PATH
rm -f /tmp/xx
/bin/sh "$@"
-42
View File
@@ -1,42 +0,0 @@
# command substution parsing tests
TABSIZE=`grep -v '^[ #]' $CAPS </dev/null | grep -v "^$" | grep -v "^capalias"| grep -v "^infoalias" | wc -l`
recho `echo ab cd #efg
hijkl`
recho ab$(echo mn; echo op)yz
a=`echo 'a b c' | sed 's/ /\\
/g' | grep 'b'`
recho $a
recho `echo 'a\' b`
recho `echo '\$' bab`
recho `echo '\`' ab`
recho `echo '\\' ab`
# old-style command substitution parsing compatibility tests -- post bash-3.1
recho 'foo \\
bar'
recho 'foo \
bar'
echo `recho sed -e 's/[ :]/\\
/g'`
echo `recho sed -e 's/[ :]/\
/g'`
echo `recho 'foo\\
bar'`
echo `recho 'foo\
bar'`
echo $(recho 'foo\
bar')
-26
View File
@@ -1,26 +0,0 @@
: $(echo \;)
: $(case a in a) echo ;;# comment
esac)
: $(case a in a) echo ;; # comment
esac)
: $(: \;# not a comment )
: $(: \ # not a comment)
echo $(case a in a) echo \#esac ;;
esac)
: $(case a in a) : ;#esac ;;
esac)
: $(case a in a) : ;#esac comment )
esac)
: $(case a in a) : ;
esac)
echo $(#comment )
echo a)
-235
View File
@@ -1,235 +0,0 @@
# first, let's start with the basics
recho "$@"
recho "$*"
recho $@
recho $*
set a b
recho "$*"
# If IFS is null, the parameters are joined without separators
IFS=''
recho "$*"
# If IFS is unset, the parameters are separated by spaces
unset IFS
recho "${*}"
recho "$@"
recho $@
IFS='/'
set bob 'tom dick harry' joe
set $*
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set ${*}
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set $@
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set ${@}
recho $#
recho $1
recho $2
recho $3
# according to POSIX.2, unquoted $* should expand to multiple words if
# $IFS is null, just like unquoted $@
IFS=''
set bob 'tom dick harry' joe
set $*
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set $@
recho $#
recho $1
recho $2
recho $3
# if IFS is unset, the individual positional parameters are split on
# " \t\n" if $* or $@ are unquoted
unset IFS
set bob 'tom dick harry' joe
set $*
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set $@
recho $#
recho $1
recho $2
recho $3
# but not for "$@" or "$*"
set bob 'tom dick harry' joe
set "$*"
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set "$@"
recho $#
recho $1
recho $2
recho $3
# POSIX.2 says these should both expand the positional parameters
# to multiple words
set a b c d e
IFS=""
recho $@
recho "$@"
# this example is straight from the POSIX.2 rationale
set foo bar bam
recho "$@"
recho "$*"
unset IFS
recho "$@"
recho $@
recho "$*"
IFS=:
# special variables
set -- 1 2 3 4 5 6 7 8 9 10
bar=${*}
foo=$*
echo foo = "$foo"
echo bar = "$bar"
foo1=$@
bar1=${@}
echo foo1 = "$foo1"
echo bar1 = "$bar1"
foo2="$*"
bar2="${*}"
echo foo2 = "$foo2"
echo bar2 = "$bar2"
eval foo3='$*' bar3='${*}'
echo foo3 = "$foo3"
echo bar3 = "$bar3"
case $* in
*\:*) echo ok 1;;
*) echo bad 1;;
esac
case $@ in
*\:*) echo bad 2;;
*) echo ok 2;;
esac
case "$*" in
*\:*) echo ok 3;;
*) echo bad 3;;
esac
case "$@" in
*\:*) echo bad 4;;
*) echo ok 4;;
esac
IFS=$' \t\n'
bar=${*}
foo=$*
echo foo = "$foo"
echo bar = "$bar"
foo1=$@
bar1=${@}
echo foo1 = "$foo1"
echo bar1 = "$bar1"
foo2="$*"
bar2="${*}"
echo foo2 = "$foo2"
echo bar2 = "$bar2"
eval foo3='$*' bar3='${*}'
echo foo3 = "$foo3"
echo bar3 = "$bar3"
case $* in
*\ *) echo ok 1;;
*) echo bad 1;;
esac
case $@ in
*\ *) echo ok 2;;
*) echo bad 2;;
esac
case "$*" in
*\ *) echo ok 3;;
*) echo bad 3;;
esac
case "$@" in
*\ *) echo ok 4;;
*) echo bad 4;;
esac
# tests for special expansion of "$*" and "${array[*]}" when used with other
# expansions -- bugs through bash-2.05b
${THIS_SH} ./dollar-star1.sub
# tests for expansion of "$@" on rhs of things like ${param:+word}. Bugs
# though bash-2.05b
${THIS_SH} ./dollar-at1.sub
# tests for expansion of other variables in double-quoted strings containing
# $@. Bugs through bash-2.05b
${THIS_SH} ./dollar-at2.sub
# tests for various expansions of $* in different contexts -- word split,
# no splitting, etc. when $IFS is NUL
${THIS_SH} ./dollar-star2.sub
# tests for expansions of "${array[*]}" and "${array[@]}" when $IFS is not the
# default and the array contains null elements
${THIS_SH} ./dollar-star3.sub
# test for set -u and expansions of $@ when there are no positional parameters
${THIS_SH} ./dollar-at3.sub
# test for set -u and expansions of $* when there are no positional parameters
${THIS_SH} ./dollar-star4.sub
exit 0
-157
View File
@@ -1,157 +0,0 @@
argv[1] = <>
argv[1] = <a b>
argv[1] = <ab>
argv[1] = <a b>
argv[1] = <a>
argv[2] = <b>
argv[1] = <a>
argv[2] = <b>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <5>
argv[1] = <bob>
argv[1] = <tom>
argv[1] = <dick>
argv[1] = <5>
argv[1] = <bob>
argv[1] = <tom>
argv[1] = <dick>
argv[1] = <1>
argv[1] = <bob>
argv[2] = <tom>
argv[3] = <dick>
argv[4] = <harry>
argv[5] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom>
argv[2] = <dick>
argv[3] = <harry>
argv[1] = <joe>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[1] = <foo>
argv[2] = <bar>
argv[3] = <bam>
argv[1] = <foobarbam>
argv[1] = <foo>
argv[2] = <bar>
argv[3] = <bam>
argv[1] = <foo>
argv[2] = <bar>
argv[3] = <bam>
argv[1] = <foo bar bam>
foo = 1:2:3:4:5:6:7:8:9:10
bar = 1:2:3:4:5:6:7:8:9:10
foo1 = 1 2 3 4 5 6 7 8 9 10
bar1 = 1 2 3 4 5 6 7 8 9 10
foo2 = 1:2:3:4:5:6:7:8:9:10
bar2 = 1:2:3:4:5:6:7:8:9:10
foo3 = 1:2:3:4:5:6:7:8:9:10
bar3 = 1:2:3:4:5:6:7:8:9:10
ok 1
ok 2
ok 3
ok 4
foo = 1 2 3 4 5 6 7 8 9 10
bar = 1 2 3 4 5 6 7 8 9 10
foo1 = 1 2 3 4 5 6 7 8 9 10
bar1 = 1 2 3 4 5 6 7 8 9 10
foo2 = 1 2 3 4 5 6 7 8 9 10
bar2 = 1 2 3 4 5 6 7 8 9 10
foo3 = 1 2 3 4 5 6 7 8 9 10
bar3 = 1 2 3 4 5 6 7 8 9 10
ok 1
ok 2
ok 3
ok 4
xa|xb|xc
xa|xb|xc
a|b|c
a|b|c
a b c
a b c
xa xb xc
xa xb xc
a|b
b|c
a b
b c
a|b|c
a|b|c
xa|xb|xc
xa|xb|xc
3
3
3
3
3
3
3
3
argv[1] = <echo 1 ; echo 1>
argv[1] = <echo 1 2 ; echo 1>
argv[2] = <2>
argv[1] = <echo 1 ; echo 1>
argv[1] = <echo 1 2 ; echo 1>
argv[2] = <2>
argv[1] = <AB>
argv[1] = <AB>
argv[1] = <A BC D>
argv[1] = <A BC D>
argv[1] = <A BC D>
argv[1] = <A B>
argv[2] = <C D>
argv[1] = <A BC D>
argv[1] = <A BC D>
argv[1] = <fooq//barq/>
argv[1] = <fooq>
argv[2] = <>
argv[3] = <barq>
argv[4] = <>
argv[1] = <foo!//bar!/>
argv[1] = <foo!>
argv[2] = <>
argv[3] = <bar!>
argv[4] = <>
argv[1] = <ooq//arq/>
argv[1] = <ooq>
argv[2] = <>
argv[3] = <arq>
argv[4] = <>
0
bar
./dollar-at3.sub: line 6: $@: unbound variable
0
bar
./dollar-star4.sub: line 6: *: unbound variable
-384
View File
@@ -1,384 +0,0 @@
#
# A suite of tests for bash word expansions
#
# This tests parameter and variable expansion, with an empahsis on
# proper quoting behavior.
#
# Chet Ramey
#
# If you comment out the body of this function, you can do a diff against
# `expansion-tests.right' to see if the shell is behaving correctly
#
expect()
{
echo expect "$@"
}
# Test the substitution quoting characters (CTLESC and CTLNUL) in different
# combinations
expect "<^A>"
recho `echo ''`
expect "<^A>"
recho `echo ""`
expect "<^B>"
recho `echo ''`
expect "<^B>"
recho `echo ""`
expect "<^A>"
recho `echo `
expect "<^B>"
recho `echo `
# Test null strings without variable expansion
expect "<abcdefgh>"
recho abcd""efgh
expect "<abcdefgh>"
recho abcd''efgh
expect "<abcdefgh>"
recho ""abcdefgh
expect "<abcdefgh>"
recho ''abcdefgh
expect "<abcd>"
recho abcd""
expect "<abcd>"
recho abcd''
# Test the quirky behavior of $@ in ""
expect nothing
recho "$@"
expect "< >"
recho " $@"
expect "<-->"
recho "-${@}-"
# Test null strings with variable expansion that fails
expect '<>'
recho $xxx""
expect '<>'
recho ""$xxx
expect '<>'
recho $xxx''
expect '<>'
recho ''$xxx
expect '<>'
recho $xxx""$yyy
expect '<>'
recho $xxx''$yyy
# Test null strings with variable expansion that succeeds
xxx=abc
yyy=def
expect '<abc>'
recho $xxx""
expect '<abc>'
recho ""$xxx
expect '<abc>'
recho $xxx''
expect '<abc>'
recho ''$xxx
expect '<abcdef>'
recho $xxx""$yyy
expect '<abcdef>'
recho $xxx''$yyy
unset xxx yyy
# Test the unquoted special quoting characters
expect "<^A>"
recho 
expect "<^B>"
recho 
expect "<^A>"
recho ""
expect "<^B>"
recho ""
expect "<^A>"
recho ''
expect "<^B>"
recho ''
# Test expansion of a variable that is unset
expect nothing
recho $xxx
expect '<>'
recho "$xxx"
expect nothing
recho "$xxx${@}"
# Test empty string expansion
expect '<>'
recho ""
expect '<>'
recho ''
# Test command substitution with (disabled) history substitution
expect '<Hello World!>'
# set +H
recho "`echo \"Hello world!\"`"
# Test some shell special characters
expect '<`>'
recho "\`"
expect '<">'
recho "\""
expect '<\^A>'
recho "\"
expect '<\$>'
recho "\\$"
expect '<\\>'
recho "\\\\"
# This should give argv[1] = a argv[2] = b
expect '<a> <b>'
FOO=`echo 'a b' | tr ' ' '\012'`
recho $FOO
# This should give argv[1] = ^A argv[2] = ^B
expect '<^A> <^B>'
FOO=`echo ' ' | tr ' ' '\012'`
recho $FOO
# Test quoted and unquoted globbing characters
expect '<**>'
recho "*"*
expect '<\.\./*/>'
recho "\.\./*/"
# Test patterns that come up when the shell quotes funny character
# combinations
expect '<^A^B^A^B>'
recho ''
expect '<^A^A>'
recho ''
expect '<^A^B>'
recho ''
expect '<^A^A^B>'
recho ''
# More tests of "$@"
set abc def ghi jkl
expect '< abc> <def> <ghi> <jkl >'
recho " $@ "
expect '< abc> <def> <ghi> <jkl >'
recho "${1+ $@ }"
set abc def ghi jkl
expect '<--abc> <def> <ghi> <jkl-->'
recho "--$@--"
set "a b" cd ef gh
expect '<a b> <cd> <ef> <gh>'
recho ${1+"$@"}
expect '<a b> <cd> <ef> <gh>'
recho ${foo:-"$@"}
expect '<a b> <cd> <ef> <gh>'
recho "${@}"
expect '< >'
recho " "
expect '< - >'
recho " - "
# Test combinations of different types of quoting in a fully-quoted string
# (so the WHOLLY_QUOTED tests fail and it doesn't get set)
expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
# Test the various Posix parameter expansions
expect '<foo bar>'
recho "${x:-$(echo "foo bar")}"
expect '<foo> <bar>'
recho ${x:-$(echo "foo bar")}
unset X
expect '<abc>'
recho ${X:=abc}
expect '<abc>'
recho $X
set a b c
expect '<posix>'
recho ${3:+posix}
POSIX=/usr/posix
expect '<10>'
recho ${#POSIX}
# remove shortest trailing match
x=file.c
expect '<file.o>'
recho ${x%.c}.o
# remove longest trailing match
x=posix/src/std
expect '<posix>'
recho ${x%%/*}
# remove shortest leading pattern
x=$HOME/src/cmd
expect '</src/cmd>'
recho ${x#$HOME}
# remove longest leading pattern
x=/one/two/three
expect '<three>'
recho ${x##*/}
# pattern removal of patterns that don't match
z=abcdef
expect '<abcdef>'
recho ${z#xyz}
expect '<abcdef>'
recho ${z##xyz}
expect '<abcdef>'
recho ${z%xyz}
expect '<abcdef>'
recho ${z%%xyz}
# Command substitution and the quirky differences between `` and $()
expect '<\$x>'
recho '\$x'
expect '<$x>'
recho `echo '\$x'`
expect '<\$x>'
recho $(echo '\$x')
# The difference between $* "$*" and "$@"
set "abc" "def ghi" "jkl"
expect '<abc> <def> <ghi> <jkl>'
recho $*
expect '<abc def ghi jkl>'
recho "$*"
OIFS="$IFS"
IFS=":$IFS"
# The special behavior of "$*", using the first character of $IFS as separator
expect '<abc:def ghi:jkl>'
recho "$*"
IFS="$OIFS"
expect '<abc> <def ghi> <jkl>'
recho "$@"
expect '<xxabc> <def ghi> <jklyy>'
recho "xx$@yy"
expect '<abc> <def ghi> <jklabc> <def ghi> <jkl>'
recho "$@$@"
foo=abc
bar=def
expect '<abcdef>'
recho "$foo""$bar"
unset foo
set $foo bar '' xyz "$foo" abc
expect '<bar> <> <xyz> <> <abc>'
recho "$@"
# More tests of quoting and deferred evaluation
foo=10 x=foo
y='$'$x
expect '<$foo>'
recho $y
eval y='$'$x
expect '<10>'
recho $y
# case statements
NL='
'
x='ab
cd'
expect '<newline expected>'
case "$x" in
*$NL*) recho "newline expected" ;;
esac
expect '<got it>'
case \? in
*"?"*) recho "got it" ;;
esac
expect '<got it>'
case \? in
*\?*) recho "got it" ;;
esac
set one two three four five
expect '<one> <three> <five>'
recho $1 $3 ${5} $8 ${9}
# length tests on positional parameters and some special parameters
expect '<5> <5>'
recho $# ${#}
expect '<3>'
recho ${#1}
expect '<1>'
recho ${##}
expect '<1>'
recho ${#?}
expect '<5>'
recho ${#@}
expect '<5>'
recho ${#*}
expect '<5>'
recho "${#@}"
expect '<5>'
recho "${#*}"
expect '<42>'
recho $((28 + 14))
expect '<26>'
recho $[ 13 * 2 ]
expect '<\>'
recho `echo \\\\`
expect '<~>'
recho '~'
expect nothing
recho $!
expect nothing
recho ${!}
# test word splitting of assignment statements not preceding a command
a="a b c d e"
declare b=$a
expect '<a> <b> <c> <d> <e>'
recho $b
a="a?b?c"
echo ${a//\\?/ }
echo ${a//\?/ }
${THIS_SH} ./exp1.sub
${THIS_SH} ./exp2.sub
-370
View File
@@ -1,370 +0,0 @@
# test the ksh-like extended globbing features: [!@*?+](patlist)
shopt -s extglob
expect()
{
echo expect "$@"
}
case "/dev/udp/129.22.8.102/45" in
/dev/@(tcp|udp)/*/*) echo ok 1;;
*) echo bad 1;;
esac
# valid numbers
case 12 in
0|[1-9]*([0-9])) echo ok 2;;
*) echo bad 2;;
esac
case 12abc in
0|[1-9]*([0-9])) echo bad 3;;
*) echo ok 3;;
esac
case 1 in
0|[1-9]*([0-9])) echo ok 4;;
*) echo bad 4;;
esac
# octal numbers
case 07 in
+([0-7])) echo ok 5;;
*) echo bad 5;;
esac
case 0377 in
+([0-7])) echo ok 6;;
*) echo bad 6;;
esac
case 09 in
+([0-7])) echo bad 7;;
*) echo ok 7;;
esac
# stuff from korn's book
case paragraph in
para@(chute|graph)) echo ok 8;;
*) echo bad 8;;
esac
case paramour in
para@(chute|graph)) echo bad 9;;
*) echo ok 9;;
esac
case para991 in
para?([345]|99)1) echo ok 10;;
*) echo bad 10;;
esac
case para381 in
para?([345]|99)1) echo bad 11;;
*) echo ok 11;;
esac
case paragraph in
para*([0-9])) echo bad 12;;
*) echo ok 12;;
esac
case para in
para*([0-9])) echo ok 13;;
*) echo bad 13;;
esac
case para13829383746592 in
para*([0-9])) echo ok 14;;
*) echo bad 14;;
esac
case paragraph in
para*([0-9])) echo bad 15;;
*) echo ok 15;;
esac
case para in
para+([0-9])) echo bad 16;;
*) echo ok 16;;
esac
case para987346523 in
para+([0-9])) echo ok 17;;
*) echo bad 17;;
esac
case paragraph in
para!(*.[0-9])) echo ok 18;;
*) echo bad 18;;
esac
case para.38 in
para!(*.[0-9])) echo ok 19;;
*) echo bad 19;;
esac
case para.graph in
para!(*.[0-9])) echo ok 20;;
*) echo bad 20;;
esac
case para39 in
para!(*.[0-9])) echo ok 21;;
*) echo bad 21;;
esac
# tests derived from those in rosenblatt's korn shell book
case "" in
*(0|1|3|5|7|9)) echo ok 22;;
*) echo bad 22;
esac
case 137577991 in
*(0|1|3|5|7|9)) echo ok 23;;
*) echo bad 23;
esac
case 2468 in
*(0|1|3|5|7|9)) echo bad 24;;
*) echo ok 24;
esac
case file.c in
*.c?(c)) echo ok 25;;
*) echo bad 25;;
esac
case file.C in
*.c?(c)) echo bad 26;;
*) echo ok 26;;
esac
case file.cc in
*.c?(c)) echo ok 27;;
*) echo bad 27;;
esac
case file.ccc in
*.c?(c)) echo bad 28;;
*) echo ok 28;;
esac
case parse.y in
!(*.c|*.h|Makefile.in|config*|README)) echo ok 29;;
*) echo bad 29;;
esac
case shell.c in
!(*.c|*.h|Makefile.in|config*|README)) echo bad 30;;
*) echo ok 30;;
esac
case Makefile in
!(*.c|*.h|Makefile.in|config*|README)) echo ok 31;;
*) echo bad 31;;
esac
case "VMS.FILE;1" in
*\;[1-9]*([0-9])) echo ok 32;;
*) echo bad 32;;
esac
case "VMS.FILE;0" in
*\;[1-9]*([0-9])) echo bad 33;;
*) echo ok 33;;
esac
case "VMS.FILE;" in
*\;[1-9]*([0-9])) echo bad 34;;
*) echo ok 34;;
esac
case "VMS.FILE;139" in
*\;[1-9]*([0-9])) echo ok 35;;
*) echo bad 35;;
esac
case "VMS.FILE;1N" in
*\;[1-9]*([0-9])) echo bad 36;;
*) echo ok 36;;
esac
# tests derived from the pd-ksh test suite
MYDIR=$PWD # save where we are
TESTDIR=/tmp/eglob-test-$$
mkdir $TESTDIR
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
touch abcx abcz bbc
expect '!([*)*'
echo !([*)*
expect '+(a|b[)*'
echo +(a|b[)*
expect '[a*(]*z'
echo [a*(]*)z
rm -f abcx abcz bbc
touch abc
expect '+()c'
echo +()c
expect '+()x'
echo +()x
expect abc
echo +(*)c
expect '+(*)x'
echo +(*)x
# extended globbing should not be performed on the output of substitutions
x='@(*)'
expect '@(*)'
echo $x
expect 'no-file+(a|b)stuff'
echo no-file+(a|b)stuff
expect 'no-file+(a*(c)|b)stuff'
echo no-file+(a*(c)|b)stuff
touch abd acd
expect 'abd acd'
echo a+(b|c)d
expect 'acd'
echo a!(@(b|B))d
expect 'abd'
echo a[b*(foo|bar)]d
# simple kleene star tests
expect no
case foo in *(a|b[)) echo yes;; *) echo no;; esac
expect yes
case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
# this doesn't work right yet; it is an incorrectly formed pattern
expect yes
case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
# check extended globbing in pattern removal -- these don't work right yet
x=abcdef
expect '1: bcdef'
echo 1: ${x#+(a|abc)}
expect '2: def'
echo 2: ${x##+(a|abc)}
expect '3: abcde'
echo 3: ${x%+(def|f)}
expect '4: abc'
echo 4: ${x%%+(f|def)}
# these work ok
expect '5: ef'
echo 5: ${x#*(a|b)cd}
expect '6: ef'
echo 6: "${x#*(a|b)cd}"
expect '7: abcdef'
echo 7: ${x#"*(a|b)cd"}
# More tests derived from a bug report concerning extended glob patterns
# following a *
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
touch ab abcdef abef abcfef
expect 'ab abef'
echo ab*(e|f)
expect 'abcfef abef'
echo ab?*(e|f)
expect abcdef
echo ab*d+(e|f)
expect 'ab abcdef abcfef abef'
echo ab**(e|f)
expect 'abcdef abcfef abef'
echo ab*+(e|f)
case 'abcfefg' in
ab**(e|f)) echo ok 37;;
*) echo bad 37;;
esac
case 'abcfefg' in
ab**(e|f)g) echo ok 38;;
*a) echo bad 38;;
esac
case ab in
ab*+(e|f)) echo bad 39;;
*) echo ok 39;;
esac
case abef in
ab***ef) echo ok 40;;
*) echo bad 40;;
esac
case abef in
ab**) echo ok 41;;
*) echo bad 41;;
esac
# bug in all versions up to and including bash-2.05b
case "123abc" in
*?(a)bc) echo ok 42;;
*) echo bad 42;;
esac
# clean up and do the next one
builtin cd /
rm -rf $TESTDIR
mkdir $TESTDIR
builtin cd $TESTDIR
LC_COLLATE=C # have to set this; it affects the sorting
touch a.b a,b a:b a-b a\;b a\ b a_b
echo a[^[:alnum:]]b
echo a[-.,:\;\ _]b
echo a@([^[:alnum:]])b
echo a@([-.,:; _])b
echo a@([.])b
echo a@([^.])b
echo a@([^x])b
echo a+([^[:alnum:]])b
echo a@(.|[^[:alnum:]])b
builtin cd /
rm -rf $TESTDIR
x=abcdef
recho "${x#*(a|b)cd}"
TEST='a , b'
shopt -s globstar
echo ${TEST//*([[:space:]]),*([[:space:]])/,}
shopt -u globstar
# this is for the benefit of pure coverage, so it writes the pcv file
# in the right place
builtin cd "$MYDIR"
${THIS_SH} ./extglob1.sub
exit 0
-39
View File
@@ -1,39 +0,0 @@
: ${TMPDIR:=/var/tmp}
dir=$PWD
shopt -s globstar
export LANG=C LC_ALL=C LC_COLLATE=C
GDIR=$TMPDIR/globstar-$$
mkdir $GDIR || exit 1
cd $GDIR || exit 1
mkdir lib builtins
mkdir lib/glob lib/readline lib/sh
touch builtins/history.o builtins/jobs.o builtins/kill.o builtins/let.o builtins/mapfile.o
touch lib/glob/glob.o lib/glob/smatch.o lib/glob/strmatch.o
touch lib/readline/bind.o lib/readline/callback.o lib/readline/compat.o lib/readline/complete.o lib/readline/display.o
touch lib/sh/casemod.o lib/sh/clktck.o lib/sh/clock.o lib/sh/eaccess.o
touch lib/sh/fdprintf.o lib/sh/fmtullong.o lib/sh/fmtulong.o lib/sh/fmtumax.o
touch lib/sh/fpurge.o lib/sh/getenv.o lib/sh/input_avail.o lib/sh/itos.o
touch alias.o
touch pcomplib.o print_cmd.o redir.o shell.o sig.o stringlib.o subst.o syntax.o
touch test.o trap.o unwind_prot.o variables.o version.o xmalloc.o y.tab.o
ls lib/**
ls lib/**/*.o
echo **/*.o
ls **
echo **
cd $dir
rm -rf $GDIR
-111
View File
@@ -1,111 +0,0 @@
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
-185
View File
@@ -1,185 +0,0 @@
# test out %+, jobs -p, and $! agreement in a subshell first
${THIS_SH} ./jobs1.sub
# test out fg/bg failure in a subshell
${THIS_SH} ./jobs2.sub
# test out behavior of waiting for background pids -- bug in versions
# before 2.03
${THIS_SH} ./jobs3.sub
# test out behavior of using job control notation when job control is not
# active
${THIS_SH} ./jobs4.sub
jobs
echo $?
# a no-such-job error, since we can use job control notation without job control
wait %1
# make sure we can't fg a job started when job control was not active
sleep 30 &
pid=$!
fg %1
# make sure the killed processes don't cause a message
exec 5>&2
exec 2>/dev/null
kill -n 9 $pid
wait # make sure we reap the processes while stderr is still redirected
exec 2>&5
echo wait-for-pid
sleep 10 &
wait $!
echo wait-errors
wait 1-1
wait -- -4
echo wait-for-background-pids
sleep 5 &
sleep 8 &
wait
echo async list wait-for-background-pids
sleep 5 & sleep 8 &
wait
echo async list wait for child
sleep 5 & echo forked
wait
echo wait-when-no-children
wait
set -m
echo wait-for-job
sleep 5 &
wait %2 # this should be a no-such-job error
echo $?
wait %1
echo async list wait-for-job
sleep 5 & echo forked
wait %1
echo fg-bg 1
sleep 5 &
%1
echo fg-bg 2
sleep 5 &
fg %%
echo fg-bg 3
sleep 5 &
fg %s
echo fg-bg 4
sleep 5 &
fg %?ee
# these next two are error cases
echo fg-bg 5
sleep 15 &
fg %2 # this should be a no-such-job error
bg %1 # this should be a `bg background job?' error
wait
# these may someday mean to start the jobs, but not print the line
# describing the status, but for now they are errors
echo fg-bg 6
sleep 5 &
fg -s %1
bg -s %1
wait
# someday this may mean to disown all stopped jobs, but for now it is
# an error
disown -s
# this is an error -- the job with the pid that is the value of $! is
# retained only until a `wait' is performed
disown %1
# this, however, is an error
disown %2
echo wait-for-non-child
wait 1
echo $?
exit 1 | exit 2 | exit 3
echo $? -- ${PIPESTATUS[@]} -- ${PIPESTATUS[0]} - ${PIPESTATUS[1]} - ${PIPESTATUS[2]}
sleep 300 &
sleep300pid=$!
echo sleep300pid = $sleep300pid
sleep 350 &
sleep 400 &
jobs
echo running jobs:
jobs -r
# should be an error
kill -n 1 %4
# should be an error
jobs %4
echo current job:
jobs %+
echo previous job:
jobs %-
kill -STOP %2
sleep 5 # give time for the shell to get the stop notification
echo after kill -STOP
echo running jobs:
jobs -r
echo stopped jobs:
jobs -s
disown %1
echo after disown
jobs
echo running jobs:
jobs -r
echo stopped jobs:
jobs -s
kill -s CONT %2
echo after kill -s CONT
echo running jobs:
jobs -r
echo stopped jobs:
jobs -s
kill -STOP %3
sleep 5 # give time for the shell to get the stop notification
echo after kill -STOP, backgrounding %3:
bg %3
disown -h %2
# make sure the killed processes don't cause a message
exec 5>&2
exec 2>/dev/null
echo killing...
kill -n 9 %2 %3
wait # make sure we reap the processes while stderr is still redirected
echo done
exec 2>&5
sleep 10 &
kill -STOP %1
sleep 5 # give time for the shell to get the stop notification
echo after KILL -STOP, foregrounding %1
fg %1
echo done
-50
View File
@@ -1,50 +0,0 @@
:; ./shx
sh:
<&$fd ok
nlbq Mon Aug 3 02:45:00 EDT 1992
bang geoff
quote 712824302
setbq defmsgid=<1992Aug3.024502.6176@host>
bgwait sleep done... wait 6187
bash:
<&$fd ok
nlbq Mon Aug 3 02:45:09 EDT 1992
bang geoff
quote 712824311
setbq defmsgid=<1992Aug3.024512.6212@host>
bgwait sleep done... wait 6223
ash:
<&$fd shx1: 4: Syntax error: Bad fd number
nlbq Mon Aug 3 02:45:19 EDT 1992
bang geoff
quote getdate: `"now"' not a valid date
setbq defmsgid=<1992Aug3.` echo 024521
bgwait sleep done... wait 6241
ksh:
<&$fd ok
nlbq ./shx: 6248 Memory fault - core dumped
bang geoff
quote getdate: `"now"' not a valid date
setbq defmsgid=<1992Aug3.024530.6257@host>
bgwait no such job: 6265
wait 6265
sleep done...
zsh:
<&$fd ok
nlbq Mon Aug 3 02:45:36 EDT 1992
bang shx3: event not found: /s/ [4]
quote 712824337
setbq defmsgid=<..6290@host>
bgwait shx7: unmatched " [9]
sleep done...
:;
-10
View File
@@ -1,10 +0,0 @@
#! /bin/sh
for cmd in sh bash ash ksh zsh
do
echo
echo $cmd:
for demo in shx?
do
$cmd $demo
done
done
-4
View File
@@ -1,4 +0,0 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./glob-test 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx glob.right && rm -f /tmp/xx
-4
View File
@@ -1,4 +0,0 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./globstar.test > /tmp/xx 2>&1
diff /tmp/xx globstar.right && rm -f /tmp/xx
-6
View File
@@ -1,6 +0,0 @@
echo "warning: UNIX versions number signals differently. If output differing" >&2
echo "warning: only in line numbers is produced, please do not consider this" >&2
echo "warning: a test failure." >&2
${THIS_SH} ./trap.tests > /tmp/xx 2>&1
diff /tmp/xx trap.right && rm -f /tmp/xx
-90
View File
@@ -1,90 +0,0 @@
# 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
-7
View File
@@ -1,7 +0,0 @@
PS4='+[$LINENO] '
trap 'echo trap: $LINENO' ERR
echo 1
echo 2
echo 3 | cat | false
echo 4
-52
View File
@@ -1,52 +0,0 @@
: ${TMPDIR:=/var/tmp}
SHELLSFILE=$TMPDIR/shells-$$
cat > $TMPDIR/shells-$$ <<EOF
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
EOF
oclosev()
{
exec {v}>&-
}
iclosev()
{
exec {v}<&-
}
exec {v}>&1
echo $v
echo foo 1 >&$v
echo foo 2 >&$v
echo foo 3 >&$v
oclosev
exec {v}<$SHELLSFILE
echo $v
while read line <&$v
do
echo $line
done
iclosev
type oclosev
type iclosev
while read -r -u ${fd}
do
echo $REPLY
done {fd}<$SHELLSFILE
rm -f $SHELLSFILE
exit 0