Imported from ../bash-2.03.tar.gz.
This commit is contained in:
parent
bc4cd23ce9
commit
b72432fdcc
191 changed files with 10113 additions and 3553 deletions
72
tests/cprint.right
Normal file
72
tests/cprint.right
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
tf is a function
|
||||
tf ()
|
||||
{
|
||||
echo this is ${0##*/} >/dev/null;
|
||||
echo a | cat - >/dev/null;
|
||||
test -f ${0##*/} && echo ${0##*/} is a regular file;
|
||||
test -d ${0##*/} || echo ${0##*/} is not a directory;
|
||||
echo a;
|
||||
echo b;
|
||||
echo c;
|
||||
echo background >/dev/null & ( exit 1 );
|
||||
echo $?;
|
||||
{
|
||||
echo a
|
||||
};
|
||||
i=0;
|
||||
while (( " i < 3 " )); do
|
||||
test -r /dev/fd/$i;
|
||||
i=$(( i + 1 ));
|
||||
done;
|
||||
[[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops >/dev/null;
|
||||
for name in $( echo 1 2 3 );
|
||||
do
|
||||
test -r /dev/fd/$name;
|
||||
done;
|
||||
if [[ -r /dev/fd/0 && -w /dev/fd/1 ]]; then
|
||||
echo ok >/dev/null;
|
||||
else
|
||||
if (( " 7 > 40 " )); then
|
||||
echo oops;
|
||||
else
|
||||
echo done;
|
||||
fi;
|
||||
fi >/dev/null;
|
||||
case $PATH in
|
||||
*$PWD*)
|
||||
echo \$PWD in \$PATH
|
||||
;;
|
||||
*)
|
||||
echo \$PWD not in \$PATH
|
||||
;;
|
||||
esac >/dev/null;
|
||||
while false; do
|
||||
echo z;
|
||||
done >/dev/null;
|
||||
until true; do
|
||||
echo z;
|
||||
done >/dev/null;
|
||||
echo \&\|'()' \{ echo abcde \; \};
|
||||
eval fu\%nc'()' \{ echo abcde \; \};
|
||||
type fu\%nc
|
||||
}
|
||||
tf2 is a function
|
||||
tf2 ()
|
||||
{
|
||||
( {
|
||||
time -p echo a | cat - >/dev/null
|
||||
} ) 2>&1
|
||||
}
|
||||
cprint.tests is a regular file
|
||||
cprint.tests is not a directory
|
||||
a
|
||||
b
|
||||
c
|
||||
1
|
||||
a
|
||||
&|() { echo abcde ; }
|
||||
fu%nc is a function
|
||||
fu%nc ()
|
||||
{
|
||||
echo abcde
|
||||
}
|
||||
67
tests/cprint.tests
Normal file
67
tests/cprint.tests
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#
|
||||
# a nonsense script and shell function to test out the command printing code
|
||||
#
|
||||
tf()
|
||||
{
|
||||
# simple command with redir
|
||||
echo this is ${0##*/} > /dev/null
|
||||
|
||||
# pipeline
|
||||
echo a | cat - > /dev/null
|
||||
|
||||
test -f ${0##*/} && echo ${0##*/} is a regular file
|
||||
test -d ${0##*/} || echo ${0##*/} is not a directory
|
||||
|
||||
echo a ; echo b ; echo c
|
||||
|
||||
echo background >/dev/null &
|
||||
|
||||
( exit 1 )
|
||||
echo $?
|
||||
|
||||
{ echo a ; }
|
||||
|
||||
i=0
|
||||
while (( i < 3 )); do
|
||||
test -r /dev/fd/$i
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
|
||||
[[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops > /dev/null
|
||||
|
||||
for name in $( echo 1 2 3 ); do
|
||||
test -r /dev/fd/$name
|
||||
done
|
||||
|
||||
if [[ -r /dev/fd/0 && -w /dev/fd/1 ]] ; then
|
||||
echo ok > /dev/null
|
||||
elif (( 7 > 40 )) ; then
|
||||
echo oops
|
||||
else
|
||||
echo done
|
||||
fi > /dev/null
|
||||
|
||||
case $PATH in
|
||||
*$PWD*) echo \$PWD in \$PATH ;;
|
||||
*) echo \$PWD not in \$PATH ;;
|
||||
esac > /dev/null
|
||||
|
||||
while false; do echo z; done > /dev/null
|
||||
|
||||
until true; do echo z ; done > /dev/null
|
||||
|
||||
echo \&\|'()' \{ echo abcde \; \}
|
||||
# when not in POSIX mode, we can have weirdly-named functions
|
||||
eval fu\%nc'()' \{ echo abcde \; \}
|
||||
type fu\%nc
|
||||
}
|
||||
|
||||
tf2()
|
||||
{
|
||||
( { time -p echo a | cat - > /dev/null ; } ) 2>&1
|
||||
}
|
||||
|
||||
type tf
|
||||
type tf2
|
||||
|
||||
tf
|
||||
|
|
@ -57,3 +57,22 @@ yes
|
|||
5: ef
|
||||
6: ef
|
||||
7: abcdef
|
||||
ab abef
|
||||
abcfef abef
|
||||
abcdef
|
||||
ab abcdef abcfef abef
|
||||
abcdef abcfef abef
|
||||
ok 37
|
||||
ok 38
|
||||
ok 39
|
||||
ok 40
|
||||
ok 41
|
||||
a b a,b a-b a.b a:b a;b a_b
|
||||
a b a,b a-b a.b a:b a;b a_b
|
||||
a b a,b a-b a.b a:b a;b a_b
|
||||
a b a,b a-b a.b a:b a;b a_b
|
||||
a.b
|
||||
a b a,b a-b a:b a;b a_b
|
||||
a b a,b a-b a.b a:b a;b a_b
|
||||
a b a,b a-b a.b a:b a;b a_b
|
||||
a b a,b a-b a.b a:b a;b a_b
|
||||
|
|
|
|||
|
|
@ -274,7 +274,74 @@ echo 6: "${x#*(a|b)cd}"
|
|||
expect '7: abcdef'
|
||||
echo 7: ${x#"*(a|b)cd"}
|
||||
|
||||
# clean up and exit
|
||||
# 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
|
||||
|
||||
# clean up and do the next one
|
||||
|
||||
builtin cd /
|
||||
rm -rf $TESTDIR
|
||||
|
||||
mkdir $TESTDIR
|
||||
builtin cd $TESTDIR
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -192,3 +192,13 @@ argv[1] = <0>
|
|||
./more-exp.tests: ${#1xyz}: bad substitution
|
||||
./more-exp.tests: #: %: syntax error: operand expected (error token is "%")
|
||||
argv[1] = <0>
|
||||
argv[1] = <a+b>
|
||||
argv[1] = <+>
|
||||
argv[1] = <+>
|
||||
argv[1] = <+>
|
||||
argv[1] = <G { I >
|
||||
argv[2] = <K>
|
||||
argv[3] = <}>
|
||||
argv[1] = <hi>
|
||||
argv[2] = <K>
|
||||
argv[3] = <}>
|
||||
|
|
|
|||
|
|
@ -434,3 +434,29 @@ recho ${#:%}
|
|||
|
||||
expect '<0>'
|
||||
recho ${#:-}
|
||||
|
||||
set --
|
||||
unset a b
|
||||
|
||||
x=a
|
||||
y=b
|
||||
|
||||
IFS=+
|
||||
|
||||
expect '<a+b>'
|
||||
recho $x+$y
|
||||
expect '<+>'
|
||||
recho $a+$b
|
||||
|
||||
expect '<+>'
|
||||
recho + "$@"
|
||||
expect '<+>'
|
||||
recho +"$@"
|
||||
|
||||
expect '<G { I>' '<K>' '<}>'
|
||||
recho ${gik:-G { I } K }
|
||||
|
||||
abc=hi
|
||||
|
||||
expect '<hi>' '<K>' '<}>'
|
||||
recho ${abc:-G { I } K }
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -83,6 +83,11 @@ printf -- "--%b--\n"
|
|||
# of the format string
|
||||
printf -- "--%b--\n" '4.2\c5.4\n'; printf "\n"
|
||||
|
||||
# make sure extra arguments are ignored if the format string doesn't
|
||||
# actually use them
|
||||
printf "\n" 4.4 BSD
|
||||
printf " " 4.4 BSD ; printf "\n"
|
||||
|
||||
# make sure that a fieldwidth and precision of `*' are handled right
|
||||
printf "%10.8s\n" 4.4BSD
|
||||
printf "%*.*s\n" 10 8 4.4BSD
|
||||
|
|
|
|||
2
tests/run-cprint
Normal file
2
tests/run-cprint
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
${THIS_SH} ./cprint.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx cprint.right && rm -f /tmp/xx
|
||||
|
|
@ -1,2 +1,5 @@
|
|||
# See whether or not we can use `diff -a'
|
||||
( diff -a ./printf.tests ./printf.tests >/dev/null 2>&1 ) && AFLAG=-a
|
||||
|
||||
${THIS_SH} ./printf.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx printf.right && rm -f /tmp/xx
|
||||
diff $AFLAG /tmp/xx printf.right && rm -f /tmp/xx
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ shopt -u mailwarn
|
|||
shopt -u nocaseglob
|
||||
shopt -u nullglob
|
||||
shopt -s promptvars
|
||||
shopt -u restricted_shell
|
||||
shopt -u shift_verbose
|
||||
shopt -s sourcepath
|
||||
--
|
||||
|
|
@ -50,6 +51,7 @@ shopt -u lithist
|
|||
shopt -u mailwarn
|
||||
shopt -u nocaseglob
|
||||
shopt -u nullglob
|
||||
shopt -u restricted_shell
|
||||
shopt -u shift_verbose
|
||||
--
|
||||
cdable_vars off
|
||||
|
|
@ -66,6 +68,7 @@ lithist off
|
|||
mailwarn off
|
||||
nocaseglob off
|
||||
nullglob off
|
||||
restricted_shell off
|
||||
shift_verbose off
|
||||
--
|
||||
set +o allexport
|
||||
|
|
|
|||
|
|
@ -222,45 +222,45 @@ t -h /tmp/test.symlink
|
|||
0
|
||||
t 4+3 -eq 7
|
||||
./test-tests: test: 4+3: integer expression expected
|
||||
1
|
||||
2
|
||||
b 4-5 -eq 7
|
||||
./test-tests: [: 4+3: integer expression expected
|
||||
1
|
||||
2
|
||||
t 9 -eq 4+5
|
||||
./test-tests: test: 4+5: integer expression expected
|
||||
1
|
||||
2
|
||||
b 9 -eq 4+5
|
||||
./test-tests: [: 4+5: integer expression expected
|
||||
1
|
||||
2
|
||||
t A -eq 7
|
||||
./test-tests: test: A: integer expression expected
|
||||
1
|
||||
2
|
||||
b A -eq 7
|
||||
./test-tests: [: A: integer expression expected
|
||||
1
|
||||
2
|
||||
t 9 -eq B
|
||||
./test-tests: test: B: integer expression expected
|
||||
1
|
||||
2
|
||||
b 9 -eq B
|
||||
./test-tests: [: B: integer expression expected
|
||||
1
|
||||
2
|
||||
t ( 1 = 2
|
||||
./test-tests: test: `)' expected
|
||||
1
|
||||
2
|
||||
b ( 1 = 2
|
||||
./test-tests: [: `)' expected, found ]
|
||||
1
|
||||
2
|
||||
./test-tests: test: a: unary operator expected
|
||||
1
|
||||
2
|
||||
./test-tests: test: b: binary operator expected
|
||||
1
|
||||
2
|
||||
./test-tests: test: -A: unary operator expected
|
||||
1
|
||||
2
|
||||
./test-tests: test: too many arguments
|
||||
1
|
||||
2
|
||||
./test-tests: test: too many arguments
|
||||
1
|
||||
2
|
||||
./test-tests: [: missing `]'
|
||||
1
|
||||
2
|
||||
./test-tests: test: (: unary operator expected
|
||||
1
|
||||
2
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
./type.tests: type: unknown option: f
|
||||
./type.tests: type: illegal option: -f
|
||||
type: usage: type [-apt] name [name ...]
|
||||
./type.tests: type: notthere: not found
|
||||
./type.tests: command: notthere: not found
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue