Imported from ../bash-3.0.tar.gz.
This commit is contained in:
parent
7117c2d221
commit
b80f6443b6
400 changed files with 69247 additions and 13346 deletions
4
tests/alias.right
Normal file
4
tests/alias.right
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
alias: 0
|
||||
alias: 0
|
||||
./alias.tests: line 25: qfoo: command not found
|
||||
quux
|
||||
37
tests/alias.tests
Normal file
37
tests/alias.tests
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# place holder for future alias testing
|
||||
shopt -s expand_aliases
|
||||
|
||||
# alias/unalias tests originally in builtins.tests
|
||||
|
||||
unalias -a
|
||||
# this should return success, according to POSIX.2
|
||||
alias
|
||||
echo alias: $?
|
||||
alias foo=bar
|
||||
unalias foo
|
||||
# this had better return success, according to POSIX.2
|
||||
alias
|
||||
echo alias: $?
|
||||
|
||||
# bug in all versions through bash-2.05b
|
||||
|
||||
unalias qfoo qbar qbaz quux 2>/dev/null
|
||||
|
||||
alias qfoo=qbar
|
||||
alias qbar=qbaz
|
||||
alias qbaz=quux
|
||||
alias quux=qfoo
|
||||
|
||||
qfoo
|
||||
|
||||
unalias qfoo qbar qbaz quux
|
||||
|
||||
unalias -a
|
||||
|
||||
alias foo='echo '
|
||||
alias bar=baz
|
||||
alias baz=quux
|
||||
|
||||
foo bar
|
||||
|
||||
unalias foo bar baz
|
||||
|
|
@ -14,39 +14,39 @@ fx is a function
|
|||
fx ()
|
||||
{
|
||||
i=0;
|
||||
for (( 1 ; i < 3 ; i++ ))
|
||||
for ((1 ; i < 3 ; i++ ))
|
||||
do
|
||||
echo $i;
|
||||
done;
|
||||
for (( i=0 ; 1 ; i++ ))
|
||||
for ((i=0 ; 1 ; i++ ))
|
||||
do
|
||||
if (( " i >= 3 " )); then
|
||||
if (( i >= 3 )); then
|
||||
break;
|
||||
fi;
|
||||
echo $i;
|
||||
done;
|
||||
for (( i=0 ; i<3 ; 1 ))
|
||||
for ((i=0 ; i<3 ; 1))
|
||||
do
|
||||
echo $i;
|
||||
(( " i++ " ));
|
||||
(( i++ ));
|
||||
done;
|
||||
i=0;
|
||||
for (( 1 ; 1 ; 1 ))
|
||||
for ((1 ; 1 ; 1))
|
||||
do
|
||||
if (( " i > 2 " )); then
|
||||
if (( i > 2 )); then
|
||||
break;
|
||||
fi;
|
||||
echo $i;
|
||||
(( " i++ " ));
|
||||
(( i++ ));
|
||||
done;
|
||||
i=0;
|
||||
for (( 1 ; 1 ; 1 ))
|
||||
for ((1 ; 1 ; 1))
|
||||
do
|
||||
if (( " i > 2 " )); then
|
||||
if (( i > 2 )); then
|
||||
break;
|
||||
fi;
|
||||
echo $i;
|
||||
(( " i++ " ));
|
||||
(( i++ ));
|
||||
done
|
||||
}
|
||||
0
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
36
|
||||
62
|
||||
63
|
||||
./arith.tests: line 143: 3425#56: illegal arithmetic base (error token is "3425#56")
|
||||
./arith.tests: line 143: 3425#56: invalid arithmetic base (error token is "3425#56")
|
||||
0
|
||||
./arith.tests: line 149: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
|
||||
./arith.tests: line 150: 2#44: value too great for base (error token is "2#44")
|
||||
|
|
@ -87,8 +87,8 @@
|
|||
./arith.tests: line 152: let: jv += $iv: syntax error: operand expected (error token is "$iv")
|
||||
./arith.tests: line 153: jv += $iv : syntax error: operand expected (error token is "$iv ")
|
||||
./arith.tests: line 154: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
|
||||
./arith.tests: line 158: 0#4: bad number (error token is "0#4")
|
||||
./arith.tests: line 159: 2#110#11: bad number (error token is "2#110#11")
|
||||
./arith.tests: line 158: 0#4: invalid number (error token is "0#4")
|
||||
./arith.tests: line 159: 2#110#11: invalid number (error token is "2#110#11")
|
||||
abc
|
||||
def
|
||||
ghi
|
||||
|
|
@ -140,13 +140,64 @@ ok
|
|||
-7
|
||||
7
|
||||
7
|
||||
./arith1.sub: line 2: 4-- : syntax error: operand expected (error token is " ")
|
||||
./arith1.sub: line 3: 4++ : syntax error: operand expected (error token is " ")
|
||||
./arith1.sub: line 4: 4 -- : syntax error: operand expected (error token is " ")
|
||||
./arith1.sub: line 5: 4 ++ : syntax error: operand expected (error token is " ")
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
||||
6
|
||||
3
|
||||
7
|
||||
4
|
||||
0
|
||||
3
|
||||
7
|
||||
2
|
||||
-2
|
||||
1
|
||||
./arith1.sub: line 35: ((: ++ : syntax error: operand expected (error token is " ")
|
||||
7
|
||||
7
|
||||
./arith1.sub: line 38: ((: -- : syntax error: operand expected (error token is " ")
|
||||
7
|
||||
7
|
||||
7
|
||||
7
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
||||
1
|
||||
0
|
||||
5
|
||||
1
|
||||
6
|
||||
2
|
||||
3
|
||||
1
|
||||
4
|
||||
0
|
||||
./arith2.sub: line 33: ((: -- : syntax error: operand expected (error token is " ")
|
||||
-7
|
||||
-7
|
||||
./arith2.sub: line 37: ((: ++ : syntax error: operand expected (error token is " ")
|
||||
7
|
||||
7
|
||||
-7
|
||||
-7
|
||||
7
|
||||
7
|
||||
8 12
|
||||
./arith.tests: line 265: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
|
||||
./arith.tests: line 269: a b: syntax error in expression (error token is "b")
|
||||
./arith.tests: line 270: ((: a b: syntax error in expression (error token is "b")
|
||||
./arith.tests: line 268: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
|
||||
./arith.tests: line 272: a b: syntax error in expression (error token is "b")
|
||||
./arith.tests: line 273: ((: a b: syntax error in expression (error token is "b")
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
./arith.tests: line 284: b[c]d: syntax error in expression (error token is "d")
|
||||
|
|
|
|||
|
|
@ -254,6 +254,9 @@ echo $(( -7 ))
|
|||
echo $(( ++7 ))
|
||||
echo $(( --7 ))
|
||||
|
||||
${THIS_SH} ./arith1.sub
|
||||
${THIS_SH} ./arith2.sub
|
||||
|
||||
x=4
|
||||
y=7
|
||||
|
||||
|
|
@ -276,3 +279,6 @@ echo $(( 8#$(printf "%o\n" $n) ))
|
|||
printf "%u\n" $n
|
||||
echo $(( 16#$(printf "%x\n" $n) ))
|
||||
echo $(( 16#$(printf "%X\n" $n) ))
|
||||
|
||||
# causes longjmp botches through bash-2.05b
|
||||
a[b[c]d]=e
|
||||
|
|
|
|||
38
tests/arith1.sub
Normal file
38
tests/arith1.sub
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# test of redone post-increment and post-decrement code
|
||||
echo $(( 4-- ))
|
||||
echo $(( 4++ ))
|
||||
echo $(( 4 -- ))
|
||||
echo $(( 4 ++ ))
|
||||
|
||||
(( array[0]++ ))
|
||||
echo ${array}
|
||||
|
||||
(( array[0] ++ ))
|
||||
echo ${array}
|
||||
|
||||
(( a++ ))
|
||||
echo $a
|
||||
(( a ++ ))
|
||||
echo $a
|
||||
|
||||
echo $(( a ++ + 4 ))
|
||||
echo $a
|
||||
|
||||
echo $(( a+++4 ))
|
||||
echo $a
|
||||
|
||||
echo $(( a---4 ))
|
||||
echo $a
|
||||
|
||||
echo $(( a -- + 4 ))
|
||||
echo $a
|
||||
|
||||
echo $(( a -- - 4 ))
|
||||
echo $a
|
||||
|
||||
(( ++ + 7 ))
|
||||
|
||||
(( ++ ))
|
||||
echo $(( +++7 ))
|
||||
echo $(( ++ + 7 ))
|
||||
(( -- ))
|
||||
45
tests/arith2.sub
Normal file
45
tests/arith2.sub
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
echo $(( --7 ))
|
||||
echo $(( ++7 ))
|
||||
echo $(( -- 7 ))
|
||||
echo $(( ++ 7 ))
|
||||
|
||||
((++array[0] ))
|
||||
echo $array
|
||||
(( ++ array[0] ))
|
||||
echo $array
|
||||
|
||||
(( ++a ))
|
||||
echo $a
|
||||
(( ++ a ))
|
||||
echo $a
|
||||
|
||||
(( --a ))
|
||||
echo $a
|
||||
(( -- a ))
|
||||
echo $a
|
||||
|
||||
echo $(( 4 + ++a ))
|
||||
echo $a
|
||||
|
||||
echo $(( 4+++a ))
|
||||
echo $a
|
||||
|
||||
echo $(( 4---a ))
|
||||
echo $a
|
||||
|
||||
echo $(( 4 - -- a ))
|
||||
echo $a
|
||||
|
||||
(( -- ))
|
||||
echo $(( ---7 ))
|
||||
echo $(( -- - 7 ))
|
||||
|
||||
(( ++ ))
|
||||
echo $(( ++7 ))
|
||||
echo $(( ++ + 7 ))
|
||||
|
||||
echo $(( ++-7 ))
|
||||
echo $(( ++ - 7 ))
|
||||
|
||||
echo $(( +--7 ))
|
||||
echo $(( -- + 7 ))
|
||||
|
|
@ -6,7 +6,12 @@ abcde
|
|||
abcde
|
||||
abcde bdef
|
||||
abcde bdef
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -a a='([0]="abcde" [1]="" [2]="bdef")'
|
||||
declare -a b='()'
|
||||
declare -ar c='()'
|
||||
|
|
@ -29,7 +34,12 @@ declare -ar c='()'
|
|||
readonly -a a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
readonly -a c='()'
|
||||
a test
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
|
||||
declare -ar c='()'
|
||||
|
|
@ -47,7 +57,12 @@ declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element
|
|||
./array.tests: line 109: []=abcde: bad array subscript
|
||||
./array.tests: line 109: [*]=last: cannot assign to non-numeric index
|
||||
./array.tests: line 109: [-65]=negative: bad array subscript
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
|
||||
declare -ar c='()'
|
||||
|
|
@ -59,7 +74,12 @@ this of
|
|||
this is a test of read using arrays
|
||||
this test
|
||||
this is a test of arrays
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
|
||||
declare -ar c='()'
|
||||
|
|
@ -127,3 +147,34 @@ abc case if then else 5
|
|||
case 4
|
||||
case if then else 5
|
||||
case if then else 5
|
||||
argv[1] = <0>
|
||||
argv[2] = <1>
|
||||
argv[3] = <4>
|
||||
argv[4] = <10>
|
||||
argv[1] = <0>
|
||||
argv[2] = <1>
|
||||
argv[3] = <4>
|
||||
argv[4] = <10>
|
||||
argv[1] = <0>
|
||||
argv[2] = <1>
|
||||
argv[3] = <4>
|
||||
argv[4] = <10>
|
||||
argv[1] = <0 1 4 10>
|
||||
include null element -- expect one
|
||||
one
|
||||
include unset element -- expect three five
|
||||
three five
|
||||
start at unset element -- expect five seven
|
||||
five seven
|
||||
too many elements -- expect three five seven
|
||||
three five seven
|
||||
positive offset - expect five seven
|
||||
five seven
|
||||
negative offset - expect five seven
|
||||
five seven
|
||||
positive offset 2 - expect seven
|
||||
seven
|
||||
negative offset 2 - expect seven
|
||||
seven
|
||||
out-of-range offset
|
||||
|
||||
|
|
|
|||
|
|
@ -289,3 +289,46 @@ echo ${foo[0]} ${#foo[0]}
|
|||
echo ${foo[1]} ${#foo[1]}
|
||||
echo ${foo[@]} ${#foo[@]}
|
||||
echo ${foo[*]} ${#foo[*]}
|
||||
|
||||
# new expansions added after bash-2.05b
|
||||
x[0]=zero
|
||||
x[1]=one
|
||||
x[4]=four
|
||||
x[10]=ten
|
||||
|
||||
recho ${!x[@]}
|
||||
recho "${!x[@]}"
|
||||
recho ${!x[*]}
|
||||
recho "${!x[*]}"
|
||||
|
||||
# sparse array tests for code fixed in bash-3.0
|
||||
unset av
|
||||
av[1]='one'
|
||||
av[2]=''
|
||||
|
||||
av[3]=three
|
||||
av[5]=five
|
||||
av[7]=seven
|
||||
|
||||
echo include null element -- expect one
|
||||
echo ${av[@]:1:2} # what happens when we include a null element?
|
||||
echo include unset element -- expect three five
|
||||
echo ${av[@]:3:2} # what happens when we include an unset element?
|
||||
echo start at unset element -- expect five seven
|
||||
echo ${av[@]:4:2} # what happens when we start at an unset element?
|
||||
|
||||
echo too many elements -- expect three five seven
|
||||
echo ${av[@]:3:5} # how about too many elements?
|
||||
|
||||
echo positive offset - expect five seven
|
||||
echo ${av[@]:5:2}
|
||||
echo negative offset - expect five seven
|
||||
echo ${av[@]: -2:2}
|
||||
|
||||
echo positive offset 2 - expect seven
|
||||
echo ${av[@]: 6:2}
|
||||
echo negative offset 2 - expect seven
|
||||
echo ${av[@]: -1:2}
|
||||
|
||||
echo out-of-range offset
|
||||
echo ${av[@]:12}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
echo ff{c,b,a}
|
||||
echo f{d,e,f}g
|
||||
echo {l,n,m}xyz
|
||||
echo {abc\,def}
|
||||
echo {abc}
|
||||
|
||||
echo \{a,b,c,d,e}
|
||||
echo {x,y,\{a,b,c}}
|
||||
echo {x\,y,\{abc\},trie}
|
||||
|
||||
echo /usr/{ucb/{ex,edit},lib/{ex,how_ex}}
|
||||
|
||||
echo XXXX\{`echo a b c | tr ' ' ','`\}
|
||||
eval echo XXXX\{`echo a b c | tr ' ' ','`\}
|
||||
|
||||
echo {}
|
||||
echo { }
|
||||
echo }
|
||||
echo {
|
||||
echo abcd{efgh
|
||||
|
||||
echo foo {1,2} bar
|
||||
echo `zecho foo {1,2} bar`
|
||||
echo $(zecho foo {1,2} bar)
|
||||
|
|
@ -17,3 +17,22 @@ abcd{efgh
|
|||
foo 1 2 bar
|
||||
foo 1 2 bar
|
||||
foo 1 2 bar
|
||||
1 2 3 4 5 6 7 8 9 10
|
||||
0..10 braces
|
||||
0 1 2 3 4 5 6 7 8 9 10 braces
|
||||
x0y x1y x2y x3y x4y x5y x6y x7y x8y x9y x10y xbracesy
|
||||
3
|
||||
x3y
|
||||
10 9 8 7 6 5 4 3 2 1
|
||||
10y 9y 8y 7y 6y 5y 4y 3y 2y 1y
|
||||
x10y x9y x8y x7y x6y x5y x4y x3y x2y x1y
|
||||
a b c d e f
|
||||
f e d c b a
|
||||
a _ ^ ] [ Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
|
||||
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] ^ _ a
|
||||
f
|
||||
{1..f}
|
||||
{f..1}
|
||||
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
|
||||
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10
|
||||
-20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
|
||||
|
|
|
|||
57
tests/braces.tests
Normal file
57
tests/braces.tests
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
echo ff{c,b,a}
|
||||
echo f{d,e,f}g
|
||||
echo {l,n,m}xyz
|
||||
echo {abc\,def}
|
||||
echo {abc}
|
||||
|
||||
echo \{a,b,c,d,e}
|
||||
echo {x,y,\{a,b,c}}
|
||||
echo {x\,y,\{abc\},trie}
|
||||
|
||||
echo /usr/{ucb/{ex,edit},lib/{ex,how_ex}}
|
||||
|
||||
echo XXXX\{`echo a b c | tr ' ' ','`\}
|
||||
eval echo XXXX\{`echo a b c | tr ' ' ','`\}
|
||||
|
||||
echo {}
|
||||
echo { }
|
||||
echo }
|
||||
echo {
|
||||
echo abcd{efgh
|
||||
|
||||
echo foo {1,2} bar
|
||||
echo `zecho foo {1,2} bar`
|
||||
echo $(zecho foo {1,2} bar)
|
||||
|
||||
# new sequence brace operators
|
||||
echo {1..10}
|
||||
|
||||
# this doesn't work yet
|
||||
echo {0..10,braces}
|
||||
# but this does
|
||||
echo {{0..10},braces}
|
||||
echo x{{0..10},braces}y
|
||||
|
||||
echo {3..3}
|
||||
echo x{3..3}y
|
||||
echo {10..1}
|
||||
echo {10..1}y
|
||||
echo x{10..1}y
|
||||
|
||||
echo {a..f}
|
||||
echo {f..a}
|
||||
|
||||
echo {a..A}
|
||||
echo {A..a}
|
||||
|
||||
echo {f..f}
|
||||
|
||||
# mixes are incorrectly-formed brace expansions
|
||||
echo {1..f}
|
||||
echo {f..1}
|
||||
|
||||
echo 0{1..9} {10..20}
|
||||
|
||||
# do negative numbers work?
|
||||
echo {-1..-10}
|
||||
echo {-20..0}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
alias: 0
|
||||
alias: 0
|
||||
a
|
||||
end-1
|
||||
a
|
||||
|
|
@ -118,15 +116,15 @@ AVAR
|
|||
foo
|
||||
declare -x foo=""
|
||||
declare -x FOO="\$\$"
|
||||
./builtins.tests: line 219: declare: FOO: not found
|
||||
./builtins.tests: line 207: declare: FOO: not found
|
||||
declare -x FOO="\$\$"
|
||||
ok
|
||||
ok
|
||||
./builtins.tests: line 251: kill: 4096: invalid signal specification
|
||||
./builtins.tests: line 239: kill: 4096: invalid signal specification
|
||||
1
|
||||
a\n\n\nb
|
||||
a
|
||||
|
||||
|
||||
b
|
||||
./builtins.tests: line 260: exit: status: numeric argument required
|
||||
./builtins.tests: line 248: exit: status: numeric argument required
|
||||
|
|
|
|||
|
|
@ -4,18 +4,6 @@ set +o posix
|
|||
|
||||
ulimit -c 0 2>/dev/null
|
||||
|
||||
# alias/unalias tests
|
||||
|
||||
unalias -a
|
||||
# this should return success, according to POSIX.2
|
||||
alias
|
||||
echo alias: $?
|
||||
alias foo=bar
|
||||
unalias foo
|
||||
# this had better return success, according to POSIX.2
|
||||
alias
|
||||
echo alias: $?
|
||||
|
||||
# check that break breaks loops
|
||||
for i in a b c; do echo $i; break; echo bad-$i; done
|
||||
echo end-1
|
||||
|
|
|
|||
|
|
@ -33,3 +33,5 @@ returns: 0
|
|||
returns: 1
|
||||
returns: 0
|
||||
ok
|
||||
ok 42
|
||||
ok 43
|
||||
|
|
|
|||
|
|
@ -153,3 +153,7 @@ PAT=
|
|||
if [[ $STR = $PAT ]]; then
|
||||
echo ok
|
||||
fi
|
||||
|
||||
# bug in all versions up to and including bash-2.05b
|
||||
if [[ "123abc" == *?(a)bc ]]; then echo ok 42; else echo bad 42; fi
|
||||
if [[ "123abc" == *?(a)bc ]]; then echo ok 43; else echo bad 43; fi
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ tf ()
|
|||
echo a
|
||||
};
|
||||
i=0;
|
||||
while (( " i < 3 " )); do
|
||||
while (( i < 3 )); do
|
||||
test -r /dev/fd/$i;
|
||||
i=$(( i + 1 ));
|
||||
done;
|
||||
|
|
@ -26,7 +26,7 @@ tf ()
|
|||
if [[ -r /dev/fd/0 && -w /dev/fd/1 ]]; then
|
||||
echo ok >/dev/null;
|
||||
else
|
||||
if (( " 7 > 40 " )); then
|
||||
if (( 7 > 40 )); then
|
||||
echo oops;
|
||||
else
|
||||
echo done;
|
||||
|
|
|
|||
353
tests/dbg-support.right
Normal file
353
tests/dbg-support.right
Normal file
|
|
@ -0,0 +1,353 @@
|
|||
debug lineno: 63 main
|
||||
debug lineno: 66 main
|
||||
FUNCNAME main
|
||||
debug lineno: 70 main
|
||||
debug lineno: 17 fn1
|
||||
debug lineno: 18 fn1
|
||||
LINENO 18
|
||||
debug lineno: 19 fn1
|
||||
LINENO 19
|
||||
debug lineno: 20 fn1
|
||||
BASH_SOURCE[0] ./dbg-support.tests
|
||||
debug lineno: 21 fn1
|
||||
FUNCNAME[0] fn1
|
||||
debug lineno: 22 fn1
|
||||
debug lineno: 22 fn1 70 ./dbg-support.tests
|
||||
debug lineno: 23 fn1
|
||||
debug lineno: 23 fn1 70 main ./dbg-support.tests
|
||||
debug lineno: 24 fn1
|
||||
debug lineno: 24 fn1
|
||||
debug lineno: 25 fn1
|
||||
./dbg-support.tests: line 25: caller: foo: invalid number
|
||||
caller: usage: caller [EXPR]
|
||||
debug lineno: 25 fn1
|
||||
debug lineno: 17 fn1
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 17 fn1
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 71 main
|
||||
debug lineno: 28 fn2
|
||||
debug lineno: 29 fn2
|
||||
fn2 here. Calling fn1...
|
||||
debug lineno: 30 fn2
|
||||
debug lineno: 17 fn1
|
||||
debug lineno: 18 fn1
|
||||
LINENO 18
|
||||
debug lineno: 19 fn1
|
||||
LINENO 19
|
||||
debug lineno: 20 fn1
|
||||
BASH_SOURCE[0] ./dbg-support.tests
|
||||
debug lineno: 21 fn1
|
||||
FUNCNAME[0] fn1
|
||||
debug lineno: 22 fn1
|
||||
debug lineno: 22 fn1 30 ./dbg-support.tests
|
||||
debug lineno: 23 fn1
|
||||
debug lineno: 23 fn1 30 fn2 ./dbg-support.tests
|
||||
debug lineno: 24 fn1
|
||||
debug lineno: 24 fn1 71 main ./dbg-support.tests
|
||||
debug lineno: 25 fn1
|
||||
./dbg-support.tests: line 25: caller: foo: invalid number
|
||||
caller: usage: caller [EXPR]
|
||||
debug lineno: 25 fn1
|
||||
debug lineno: 17 fn1
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 17 fn1
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 28 fn2
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 28 fn2
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 72 main
|
||||
debug lineno: 33 fn3
|
||||
debug lineno: 34 fn3
|
||||
LINENO 34
|
||||
debug lineno: 35 fn3
|
||||
BASH_SOURCE[0] ./dbg-support.tests
|
||||
debug lineno: 38 fn3
|
||||
debug lineno: 39 fn3
|
||||
debug lineno: 40 fn3
|
||||
debug lineno: 40 fn3
|
||||
debug lineno: 41 fn3
|
||||
debug lineno: 42 fn3
|
||||
debug lineno: 43 fn3
|
||||
fn3 called from file `./dbg-support.tests' at line 0
|
||||
debug lineno: 40 fn3
|
||||
debug lineno: 40 fn3
|
||||
debug lineno: 41 fn3
|
||||
debug lineno: 42 fn3
|
||||
debug lineno: 42 fn3
|
||||
debug lineno: 43 fn3
|
||||
main called from file `./dbg-support.tests' at line 0
|
||||
debug lineno: 40 fn3
|
||||
debug lineno: 40 fn3
|
||||
debug lineno: 46 fn3
|
||||
debug lineno: 18 source
|
||||
SOURCED LINENO 18
|
||||
debug lineno: 19 source
|
||||
SOURCED BASH_SOURCE[0] ./dbg-support.sub
|
||||
debug lineno: 20 source
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 4 sourced_fn
|
||||
debug lineno: 5 sourced_fn
|
||||
SOURCED FN LINENO 5
|
||||
debug lineno: 8 sourced_fn
|
||||
debug lineno: 9 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[1]: source called from ./dbg-support.tests at line 46
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 72
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[3]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 3 sourced_fn
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 46 fn3
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 46 fn3
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 33 fn3
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 33 fn3
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 73 main
|
||||
debug lineno: 18 source
|
||||
SOURCED LINENO 18
|
||||
debug lineno: 19 source
|
||||
SOURCED BASH_SOURCE[0] ./dbg-support.sub
|
||||
debug lineno: 20 source
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 4 sourced_fn
|
||||
debug lineno: 5 sourced_fn
|
||||
SOURCED FN LINENO 5
|
||||
debug lineno: 8 sourced_fn
|
||||
debug lineno: 9 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[1]: source called from ./dbg-support.tests at line 73
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[2]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 3 sourced_fn
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 73 main
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 73 main
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 76 main
|
||||
debug lineno: 79 main
|
||||
LINENO 18
|
||||
LINENO 19
|
||||
BASH_SOURCE[0] ./dbg-support.tests
|
||||
FUNCNAME[0] fn1
|
||||
79 ./dbg-support.tests
|
||||
79 main ./dbg-support.tests
|
||||
|
||||
./dbg-support.tests: line 25: caller: foo: invalid number
|
||||
caller: usage: caller [EXPR]
|
||||
|
||||
debug lineno: 80 main
|
||||
fn2 here. Calling fn1...
|
||||
LINENO 18
|
||||
LINENO 19
|
||||
BASH_SOURCE[0] ./dbg-support.tests
|
||||
FUNCNAME[0] fn1
|
||||
30 ./dbg-support.tests
|
||||
30 fn2 ./dbg-support.tests
|
||||
80 main ./dbg-support.tests
|
||||
./dbg-support.tests: line 25: caller: foo: invalid number
|
||||
caller: usage: caller [EXPR]
|
||||
|
||||
debug lineno: 81 main
|
||||
LINENO 34
|
||||
BASH_SOURCE[0] ./dbg-support.tests
|
||||
fn3 called from file `./dbg-support.tests' at line 0
|
||||
main called from file `./dbg-support.tests' at line 0
|
||||
SOURCED LINENO 18
|
||||
SOURCED BASH_SOURCE[0] ./dbg-support.sub
|
||||
SOURCED FN LINENO 5
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
|
||||
FUNCNAME[1]: source called from ./dbg-support.tests at line 46
|
||||
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 81
|
||||
FUNCNAME[3]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 82 main
|
||||
fn4 here. Calling fn3...
|
||||
LINENO 34
|
||||
BASH_SOURCE[0] ./dbg-support.tests
|
||||
fn3 called from file `./dbg-support.tests' at line 82
|
||||
fn4 called from file `./dbg-support.tests' at line 0
|
||||
main called from file `./dbg-support.tests' at line 0
|
||||
SOURCED LINENO 18
|
||||
SOURCED BASH_SOURCE[0] ./dbg-support.sub
|
||||
SOURCED FN LINENO 5
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
|
||||
FUNCNAME[1]: source called from ./dbg-support.tests at line 46
|
||||
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 51
|
||||
FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 82
|
||||
FUNCNAME[4]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 83 main
|
||||
SOURCED LINENO 18
|
||||
SOURCED BASH_SOURCE[0] ./dbg-support.sub
|
||||
SOURCED FN LINENO 5
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
|
||||
FUNCNAME[1]: source called from ./dbg-support.tests at line 83
|
||||
FUNCNAME[2]: main called from ./dbg-support.tests at line 0
|
||||
return lineno: 83 main
|
||||
debug lineno: 86 main
|
||||
debug lineno: 89 main
|
||||
debug lineno: 18 source
|
||||
SOURCED LINENO 18
|
||||
debug lineno: 19 source
|
||||
SOURCED BASH_SOURCE[0] ./dbg-support.sub
|
||||
debug lineno: 20 source
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 4 sourced_fn
|
||||
debug lineno: 5 sourced_fn
|
||||
SOURCED FN LINENO 5
|
||||
debug lineno: 8 sourced_fn
|
||||
debug lineno: 9 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[1]: source called from ./dbg-support.tests at line 89
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[2]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 3 sourced_fn
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 89 main
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 89 main
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 90 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 94 main
|
||||
debug lineno: 97 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 94 main
|
||||
debug lineno: 97 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 94 main
|
||||
debug lineno: 95 main
|
||||
Hit 2
|
||||
debug lineno: 97 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 93 main
|
||||
debug lineno: 103 main
|
||||
SOURCED FN LINENO 5 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 103 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 104 main
|
||||
SOURCED FN LINENO 5 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 104 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 105 main
|
||||
debug lineno: 106 main
|
||||
SOURCED FN LINENO 5
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 106
|
||||
FUNCNAME[1]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 110 main
|
||||
debug lineno: 111 main
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 4 sourced_fn
|
||||
debug lineno: 5 sourced_fn
|
||||
SOURCED FN LINENO 5
|
||||
debug lineno: 8 sourced_fn
|
||||
debug lineno: 9 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 111
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 11 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 12 sourced_fn
|
||||
debug lineno: 13 sourced_fn
|
||||
FUNCNAME[1]: main called from ./dbg-support.tests at line 0
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 10 sourced_fn
|
||||
debug lineno: 3 sourced_fn
|
||||
debug lineno: 12 print_return_trap
|
||||
debug lineno: 13 print_return_trap
|
||||
return lineno: 3 sourced_fn
|
||||
debug lineno: 14 print_return_trap
|
||||
debug lineno: 114 main
|
||||
debug lineno: 119 main
|
||||
debug lineno: 123 main
|
||||
got it
|
||||
debug lineno: 131 main
|
||||
debug lineno: 132 main
|
||||
debug lineno: 133 main
|
||||
debug lineno: 132 main
|
||||
debug lineno: 133 main
|
||||
debug lineno: 131 main
|
||||
debug lineno: 132 main
|
||||
debug lineno: 133 main
|
||||
debug lineno: 132 main
|
||||
debug lineno: 133 main
|
||||
26
tests/dbg-support.sub
Normal file
26
tests/dbg-support.sub
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# This file is intended to be sourced from one of the bashdb test programs
|
||||
|
||||
sourced_fn() {
|
||||
name="fn2"
|
||||
echo "SOURCED FN LINENO $LINENO"
|
||||
|
||||
# Print a stack trace
|
||||
declare -i n
|
||||
n=${#FUNCNAME[@]}
|
||||
for (( i=0 ; (( i < $n )) ; i++ )) ; do
|
||||
local -i j=i+1
|
||||
[ $j -eq $n ] && j=i # main()'s file is the same as the first caller
|
||||
echo "FUNCNAME[$i]: ${FUNCNAME[$i]} called from ${BASH_SOURCE[$j]}" \
|
||||
"at line ${BASH_LINENO[$i]}"
|
||||
done
|
||||
}
|
||||
|
||||
echo "SOURCED LINENO $LINENO"
|
||||
echo "SOURCED BASH_SOURCE[0]" ${BASH_SOURCE[0]}
|
||||
sourced_fn
|
||||
|
||||
#;;; Local Variables: ***
|
||||
#;;; mode:shell-script ***
|
||||
#;;; eval: (sh-set-shell "bash") ***
|
||||
#;;; End: ***
|
||||
|
||||
139
tests/dbg-support.tests
Executable file
139
tests/dbg-support.tests
Executable file
|
|
@ -0,0 +1,139 @@
|
|||
#!../bash
|
||||
#
|
||||
# Test correct functioning bash debug support not via the bashdb
|
||||
# debugger but merely by printing via print_trap()
|
||||
# $Id: dbg-support.tests,v 1.13 2003/02/17 22:02:25 rockyb Exp $
|
||||
shopt -s extdebug
|
||||
print_debug_trap() {
|
||||
echo "debug lineno: $1 ${FUNCNAME[1]}"
|
||||
return
|
||||
}
|
||||
|
||||
print_return_trap() {
|
||||
echo "return lineno: $1 ${FUNCNAME[1]}"
|
||||
return
|
||||
}
|
||||
|
||||
fn1() {
|
||||
echo "LINENO $LINENO"
|
||||
echo "LINENO $LINENO"
|
||||
echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
|
||||
echo "FUNCNAME[0]" ${FUNCNAME[0]}
|
||||
echo `caller`
|
||||
echo `caller 0`
|
||||
echo `caller 1`
|
||||
echo `caller foo`
|
||||
}
|
||||
|
||||
fn2() {
|
||||
echo "fn2 here. Calling fn1..."
|
||||
fn1
|
||||
}
|
||||
|
||||
fn3() {
|
||||
echo "LINENO $LINENO"
|
||||
echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
|
||||
|
||||
# Print a stack trace
|
||||
declare -i n
|
||||
n=${#FUNCNAME[@]}
|
||||
for (( i=0 ; (( i < $n )) ; i++ )) ; do
|
||||
local -i j=i+1
|
||||
[ $j -eq $n ] && j=i # main()'s file is the same as the first caller
|
||||
echo "${FUNCNAME[$i]} called from file " \
|
||||
"\`${BASH_SOURCE[$j]}' at line ${BASH_LINENO[$j]}"
|
||||
done
|
||||
source ./dbg-support.sub
|
||||
}
|
||||
|
||||
fn4() {
|
||||
echo "fn4 here. Calling fn3..."
|
||||
fn3
|
||||
}
|
||||
|
||||
|
||||
#!../bash
|
||||
#
|
||||
# Test of support for debugging facilities in bash
|
||||
#
|
||||
# Test debugger set option fntrace - set on. Not in vanilla Bash 2.05
|
||||
#
|
||||
set -o functrace
|
||||
trap 'print_debug_trap $LINENO' DEBUG
|
||||
trap 'print_return_trap $LINENO' RETURN
|
||||
|
||||
# Funcname is now an array. Vanilla Bash 2.05 doesn't have FUNCNAME array.
|
||||
echo "FUNCNAME" ${FUNCNAME[0]}
|
||||
|
||||
# We should trace into the below.
|
||||
# Start easy with a simple function.
|
||||
fn1
|
||||
fn2
|
||||
fn3
|
||||
source ./dbg-support.sub
|
||||
|
||||
# Test debugger set option fntrace - set off
|
||||
set +T
|
||||
|
||||
# We should not trace into this.
|
||||
fn1
|
||||
fn2
|
||||
fn3
|
||||
fn4
|
||||
source ./dbg-support.sub
|
||||
|
||||
# Another way to say: set -o fntrace
|
||||
set -T
|
||||
|
||||
# We should trace into this.
|
||||
source ./dbg-support.sub
|
||||
set +T
|
||||
|
||||
# Test that the line numbers in the presence of conditionals are correct.
|
||||
for (( i=0 ; (( i <= 2 )) ; i++ )) ; do
|
||||
if [ $i -eq 2 ] ; then
|
||||
echo "Hit 2"
|
||||
fi
|
||||
j=4
|
||||
done
|
||||
|
||||
#
|
||||
# Check line numbers in command substitution
|
||||
#
|
||||
echo $(sourced_fn)
|
||||
echo `sourced_fn`
|
||||
x=$((sourced_fn))
|
||||
x={ sourced_fn }
|
||||
|
||||
# Make sure we step into sourced_fn as a comand when we request to do so.
|
||||
# Vanilla bash 2.0 doesn't do.
|
||||
set -o functrace
|
||||
x={ sourced_fn }
|
||||
|
||||
# Should see line number of xyzzy below. Vanilla bash 2.05b doesn't do
|
||||
case xyzzy in
|
||||
a )
|
||||
x=5
|
||||
;;
|
||||
xyzz? )
|
||||
case 3 in
|
||||
2 )
|
||||
x=6 ;;
|
||||
3 )
|
||||
echo "got it" ;;
|
||||
* ) echo "no good" ;;
|
||||
esac
|
||||
;;
|
||||
* )
|
||||
esac
|
||||
|
||||
# Should see line numbers for initial for lines.
|
||||
for i in 0 1 ; do
|
||||
for j in 3 4 ; do
|
||||
((x=i+j))
|
||||
done
|
||||
done
|
||||
#;;; Local Variables: ***
|
||||
#;;; mode:shell-script ***
|
||||
#;;; eval: (sh-set-shell "bash") ***
|
||||
#;;; End: ***
|
||||
7
tests/dbg-support2.right
Normal file
7
tests/dbg-support2.right
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
lineno: 17 (6) main
|
||||
lineno: 18 (6) main
|
||||
x is 1
|
||||
lineno: 19 (6) main
|
||||
lineno: 20 (6) main
|
||||
lineno: 21 (6) main
|
||||
x is 1
|
||||
26
tests/dbg-support2.tests
Executable file
26
tests/dbg-support2.tests
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!../bash
|
||||
#
|
||||
# Test correct trap return codes = 2 means skip execution.
|
||||
shopt -s extdebug
|
||||
print_trap() {
|
||||
echo "lineno: $1 ($LINENO) ${FUNCNAME[1]}"
|
||||
if [[ $debug_exit == 2 ]] ; then
|
||||
debug_exit=0
|
||||
return 2
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
debug_exit=0
|
||||
trap 'print_trap $LINENO' DEBUG
|
||||
|
||||
x=1
|
||||
echo "x is $x"
|
||||
debug_exit=2
|
||||
x=2
|
||||
echo "x is $x"
|
||||
|
||||
#;;; Local Variables: ***
|
||||
#;;; mode:shell-script ***
|
||||
#;;; eval: (sh-set-shell "bash") ***
|
||||
#;;; End: ***
|
||||
|
|
@ -207,4 +207,16 @@ case "$@" in
|
|||
*) 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
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
29
tests/dollar-at1.sub
Normal file
29
tests/dollar-at1.sub
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
echo_argc()
|
||||
{
|
||||
echo $#
|
||||
}
|
||||
|
||||
a()
|
||||
{
|
||||
shift
|
||||
echo_argc "$@"
|
||||
echo_argc ${1:+"$@"}
|
||||
echo_argc "${1:+$@}"
|
||||
echo_argc 1 2 3
|
||||
}
|
||||
|
||||
b()
|
||||
{
|
||||
_IFS="$IFS"
|
||||
IFS="$1"
|
||||
shift
|
||||
echo_argc "$@"
|
||||
echo_argc ${1:+"$@"}
|
||||
echo_argc "${1:+$@}"
|
||||
echo_argc 1 2 3
|
||||
IFS="$_IFS"
|
||||
}
|
||||
|
||||
a "X" foo bar hoge
|
||||
|
||||
b "X" foo bar hoge
|
||||
19
tests/dollar-at2.sub
Normal file
19
tests/dollar-at2.sub
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
t1()
|
||||
{
|
||||
xxx="echo $@"
|
||||
|
||||
recho "$xxx ; echo $@"
|
||||
}
|
||||
|
||||
t2()
|
||||
{
|
||||
xxx="echo $@"
|
||||
|
||||
recho "${xxx} ; echo $@"
|
||||
}
|
||||
|
||||
t1 1
|
||||
t1 1 2
|
||||
|
||||
t2 1
|
||||
t2 1 2
|
||||
31
tests/dollar-star1.sub
Normal file
31
tests/dollar-star1.sub
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
set -- a b c
|
||||
x=(a b c); IFS='|'
|
||||
|
||||
echo "${*/#/x}"
|
||||
echo "${x[*]/#/x}"
|
||||
|
||||
echo "$*"
|
||||
echo "${x[*]}"
|
||||
|
||||
echo "$@"
|
||||
echo "${x[@]}"
|
||||
|
||||
echo "${@/#/x}"
|
||||
echo "${x[@]/#/x}"
|
||||
|
||||
echo "${*:1:2}"
|
||||
echo "${x[*]:1:2}"
|
||||
|
||||
echo "${@:1:2}"
|
||||
echo "${x[@]:1:2}"
|
||||
|
||||
IFS=$' \t\n'
|
||||
set -- xa xb xc
|
||||
x=(xa xb xc)
|
||||
IFS='|'
|
||||
|
||||
echo "${*#x}"
|
||||
echo "${x[*]#x}"
|
||||
|
||||
echo "$*"
|
||||
echo "${x[*]}"
|
||||
|
|
@ -95,3 +95,33 @@ 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>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
./errors.tests: line 17: alias: -x: invalid option
|
||||
alias: usage: alias [-p] [name[=value] ... ]
|
||||
./errors.tests: line 18: unalias: -x: invalid option
|
||||
unalias: usage: unalias [-a] [name ...]
|
||||
unalias: usage: unalias [-a] name [name ...]
|
||||
./errors.tests: line 19: alias: hoowah: not found
|
||||
./errors.tests: line 20: unalias: hoowah: not found
|
||||
./errors.tests: line 23: `1': not a valid identifier
|
||||
|
|
@ -15,7 +15,7 @@ unset: usage: unset [-f] [-v] [name ...]
|
|||
./errors.tests: line 52: unset: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 55: unset: cannot simultaneously unset a function and a variable
|
||||
./errors.tests: line 58: declare: -z: invalid option
|
||||
declare: usage: declare [-afFirtx] [-p] name[=value] ...
|
||||
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
|
||||
./errors.tests: line 60: declare: `-z': not a valid identifier
|
||||
./errors.tests: line 61: declare: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 65: declare: cannot use `-f' to make functions
|
||||
|
|
@ -53,20 +53,20 @@ umask: usage: umask [-p] [-S] [mode]
|
|||
./errors.tests: line 159: declare: VAR: readonly variable
|
||||
./errors.tests: line 161: declare: unset: not found
|
||||
./errors.tests: line 164: VAR: readonly variable
|
||||
./errors.tests: command substitution: line 2: syntax error: unexpected end of file
|
||||
./errors.tests: command substitution: line 1: syntax error near unexpected token `done'
|
||||
./errors.tests: command substitution: line 1: ` for z in 1 2 3; done '
|
||||
./errors.tests: command substitution: line 168: syntax error: unexpected end of file
|
||||
./errors.tests: command substitution: line 168: syntax error near unexpected token `done'
|
||||
./errors.tests: command substitution: line 168: ` for z in 1 2 3; done '
|
||||
./errors.tests: line 171: cd: HOME not set
|
||||
./errors.tests: line 172: cd: /tmp/xyz.bash: No such file or directory
|
||||
./errors.tests: line 174: cd: OLDPWD not set
|
||||
./errors.tests: line 175: cd: /bin/sh: Not a directory
|
||||
./errors.tests: line 177: cd: /tmp/cd-notthere: No such file or directory
|
||||
./errors.tests: line 180: .: filename argument required
|
||||
.: usage: . filename
|
||||
.: usage: . filename [arguments]
|
||||
./errors.tests: line 181: source: filename argument required
|
||||
source: usage: source filename
|
||||
source: usage: source filename [arguments]
|
||||
./errors.tests: line 184: .: -i: invalid option
|
||||
.: usage: . filename
|
||||
.: usage: . filename [arguments]
|
||||
./errors.tests: line 187: set: -q: invalid option
|
||||
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
|
||||
./errors.tests: line 190: enable: sh: not a shell builtin
|
||||
|
|
@ -76,16 +76,16 @@ set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
|
|||
./errors.tests: line 199: read: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 202: VAR: readonly variable
|
||||
./errors.tests: line 205: readonly: -x: invalid option
|
||||
readonly: usage: readonly [-anf] [name[=value] ...] or readonly -p
|
||||
readonly: usage: readonly [-af] [name[=value] ...] or readonly -p
|
||||
./errors.tests: line 208: eval: -i: invalid option
|
||||
eval: usage: eval [arg ...]
|
||||
./errors.tests: line 209: command: -i: invalid option
|
||||
command: usage: command [-pVv] command [arg ...]
|
||||
./errors.tests: line 1: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 1: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 212: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 213: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 216: trap: NOSIG: invalid signal specification
|
||||
./errors.tests: line 219: trap: -s: invalid option
|
||||
trap: usage: trap [arg] [signal_spec ...] or trap -l
|
||||
trap: usage: trap [-lp] [[arg] signal_spec ...]
|
||||
./errors.tests: line 225: return: can only `return' from a function or sourced script
|
||||
./errors.tests: line 229: break: 0: loop count out of range
|
||||
./errors.tests: line 233: continue: 0: loop count out of range
|
||||
|
|
|
|||
|
|
@ -6,15 +6,15 @@ after exec1.sub with args: 0
|
|||
after exec1.sub without args: 0
|
||||
./execscript: line 20: notthere: command not found
|
||||
127
|
||||
notthere: notthere: No such file or directory
|
||||
/tmp/bash: notthere: No such file or directory
|
||||
127
|
||||
/bin/sh: /bin/sh: cannot execute binary file
|
||||
126
|
||||
./execscript: line 32: /: is a directory
|
||||
./execscript: line 39: /: is a directory
|
||||
126
|
||||
/: /: cannot execute binary file
|
||||
126
|
||||
./execscript: line 39: .: /: is a directory
|
||||
./execscript: line 46: .: /: is a directory
|
||||
1
|
||||
127
|
||||
0
|
||||
|
|
@ -22,11 +22,11 @@ this is bashenv
|
|||
./exec3.sub: line 3: /tmp/bash-notthere: No such file or directory
|
||||
./exec3.sub: line 3: exec: /tmp/bash-notthere: cannot execute: No such file or directory
|
||||
126
|
||||
./execscript: line 61: notthere: No such file or directory
|
||||
./execscript: line 68: notthere: No such file or directory
|
||||
127
|
||||
./execscript: line 64: notthere: No such file or directory
|
||||
./execscript: line 71: notthere: No such file or directory
|
||||
127
|
||||
./execscript: line 67: notthere: No such file or directory
|
||||
./execscript: line 74: notthere: No such file or directory
|
||||
127
|
||||
this is sh
|
||||
this is sh
|
||||
|
|
@ -50,3 +50,4 @@ this is ohio-state
|
|||
1
|
||||
0
|
||||
1
|
||||
testb
|
||||
|
|
|
|||
20
tests/exec7.sub
Normal file
20
tests/exec7.sub
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# make sure that bash really checks the right things when deciding what
|
||||
# constitutes an executable file
|
||||
|
||||
[ $UID -eq 0 ] && { echo "exec7.sub: the test suite should not be run as root" >&2 ; }
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
|
||||
cd $TMPDIR || { echo "cannot cd to $TMPDIR" >&2 ; exit 2; }
|
||||
|
||||
mkdir testa testb
|
||||
|
||||
echo 'echo "testa"' > testa/foo
|
||||
echo 'echo "testb"' > testb/foo
|
||||
|
||||
chmod 655 testa/foo
|
||||
chmod 755 testb/foo
|
||||
|
||||
PATH=$TMPDIR/testa:$TMPDIR/testb $THIS_SH -c foo
|
||||
|
||||
rm -rf testa testb
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
if (( $UID == 0 )); then
|
||||
if [ $UID -eq 0 ]; then
|
||||
echo "execscript: the test suite should not be run as root" >&2
|
||||
fi
|
||||
|
||||
|
|
@ -21,8 +21,15 @@ notthere
|
|||
echo $?
|
||||
|
||||
# this is iffy, since the error messages may vary from system to system
|
||||
${THIS_SH} notthere
|
||||
# and /tmp might not exist
|
||||
ln -s ${THIS_SH} /tmp/bash 2>/dev/null
|
||||
if [ -f /tmp/bash ]; then
|
||||
/tmp/bash notthere
|
||||
else
|
||||
${THIS_SH} notthere
|
||||
fi
|
||||
echo $?
|
||||
rm -f /tmp/bash
|
||||
|
||||
# /bin/sh should be there on all systems
|
||||
${THIS_SH} /bin/sh
|
||||
|
|
@ -94,3 +101,6 @@ ${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
|
|||
# values
|
||||
|
||||
${THIS_SH} ./exec6.sub
|
||||
|
||||
# checks for properly deciding what constitutes an executable file
|
||||
${THIS_SH} ./exec7.sub
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ ok 38
|
|||
ok 39
|
||||
ok 40
|
||||
ok 41
|
||||
ok 42
|
||||
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
|
||||
|
|
|
|||
|
|
@ -321,6 +321,12 @@ 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 /
|
||||
|
|
|
|||
|
|
@ -35,6 +35,16 @@ recho a* X*
|
|||
|
||||
shopt -u nullglob
|
||||
|
||||
# see if the failglob option works
|
||||
|
||||
mkdir tmp
|
||||
touch tmp/l1 tmp/l2 tmp/l3
|
||||
builtin echo tmp/l[12] tmp/*4 tmp/*3
|
||||
shopt -s failglob
|
||||
builtin echo tmp/l[12] tmp/*4 tmp/*3
|
||||
rm -r tmp
|
||||
shopt -u failglob
|
||||
|
||||
# see if the code that expands directories only works
|
||||
expect '<bdir/>'
|
||||
recho b*/
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ argv[1] = <a>
|
|||
argv[2] = <abc>
|
||||
argv[3] = <abd>
|
||||
argv[4] = <abe>
|
||||
tmp/l1 tmp/l2 tmp/*4 tmp/l3
|
||||
./glob-test: line 44: no match: tmp/*4
|
||||
argv[1] = <bdir/>
|
||||
argv[1] = <*>
|
||||
argv[1] = <a*>
|
||||
|
|
|
|||
|
|
@ -24,3 +24,5 @@ f3 ()
|
|||
echo $(echo hi)
|
||||
echo ho
|
||||
echo off to work we go
|
||||
declare -a uu='([0]="" [1]="kghfjk" [2]="jkfzuk" [3]="i\
|
||||
")'
|
||||
|
|
|
|||
|
|
@ -34,3 +34,6 @@ cat <<< 'echo $(echo hi)'
|
|||
cat <<< "echo ho"
|
||||
|
||||
cat <<< "echo $(echo off to work we go)"
|
||||
|
||||
IFS="/" read -r -d $'\000' -a uu <<< /kghfjk/jkfzuk/i
|
||||
declare -p uu
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ echo 'xwhix.h'
|
|||
xwhix.h
|
||||
echo 'xwhix.h'
|
||||
xwhix.h
|
||||
7 set -H
|
||||
8 echo line 2 for history
|
||||
9 echo a b c d e
|
||||
10 echo line 2 for history
|
||||
|
|
@ -117,9 +118,8 @@ xwhix.h
|
|||
34 echo bar.c bar.o bar.html bar.h
|
||||
35 echo xbar.c xbar.o xbar.html xbar.h
|
||||
36 echo xwhix.c xwhix.o xwhix.html xwhix.h
|
||||
37 echo xwhix.c xwhix.o xwhix.html xwhix.h
|
||||
38 echo 'xwhix'
|
||||
39 echo 'xwhix.h'
|
||||
37 echo 'xwhix'
|
||||
38 echo 'xwhix.h'
|
||||
!!
|
||||
!!
|
||||
echo '!!' \!\!
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
./jobs2.sub: line 9: fg: job %1 started without job control
|
||||
./jobs2.sub: line 9: fg: job 1 started without job control
|
||||
fg: 1
|
||||
Waiting for job 0
|
||||
job 0 returns 0
|
||||
|
|
@ -16,20 +16,28 @@ Waiting for job 6
|
|||
job 6 returns 0
|
||||
Waiting for job 7
|
||||
job 7 returns 0
|
||||
[1] Running sleep 5 &
|
||||
[2] Running sleep 5 &
|
||||
[3] Running sleep 5 &
|
||||
[4]- Running sleep 5 &
|
||||
[5]+ Running ( sleep 5; exit 4 ) &
|
||||
4
|
||||
0
|
||||
./jobs.tests: line 15: wait: no job control
|
||||
./jobs.tests: line 20: fg: no job control
|
||||
i killed it
|
||||
0
|
||||
./jobs.tests: line 19: wait: %1: no such job
|
||||
./jobs.tests: line 24: fg: no job control
|
||||
wait-for-pid
|
||||
wait-errors
|
||||
./jobs.tests: line 33: wait: `1-1': not a pid or valid job spec
|
||||
./jobs.tests: line 34: wait: `-4': not a pid or valid job spec
|
||||
./jobs.tests: line 37: wait: `1-1': not a pid or valid job spec
|
||||
./jobs.tests: line 38: wait: `-4': not a pid or valid job spec
|
||||
wait-for-background-pids
|
||||
async list wait-for-background-pids
|
||||
async list wait for child
|
||||
forked
|
||||
wait-when-no-children
|
||||
wait-for-job
|
||||
./jobs.tests: line 56: wait: %2: no such job
|
||||
./jobs.tests: line 60: wait: %2: no such job
|
||||
127
|
||||
async list wait-for-job
|
||||
forked
|
||||
|
|
@ -42,19 +50,19 @@ sleep 5
|
|||
fg-bg 4
|
||||
sleep 5
|
||||
fg-bg 5
|
||||
./jobs.tests: line 83: fg: %2: no such job
|
||||
./jobs.tests: line 84: bg: bg background job?
|
||||
./jobs.tests: line 87: fg: %2: no such job
|
||||
./jobs.tests: line 88: bg: job 1 already in background
|
||||
fg-bg 6
|
||||
./jobs.tests: line 91: fg: -s: invalid option
|
||||
./jobs.tests: line 95: fg: -s: invalid option
|
||||
fg: usage: fg [job_spec]
|
||||
./jobs.tests: line 92: bg: -s: invalid option
|
||||
./jobs.tests: line 96: bg: -s: invalid option
|
||||
bg: usage: bg [job_spec]
|
||||
./jobs.tests: line 97: disown: -s: invalid option
|
||||
./jobs.tests: line 101: disown: -s: invalid option
|
||||
disown: usage: disown [-h] [-ar] [jobspec ...]
|
||||
./jobs.tests: line 101: disown: %1: no such job
|
||||
./jobs.tests: line 104: disown: %2: no such job
|
||||
./jobs.tests: line 105: disown: %1: no such job
|
||||
./jobs.tests: line 108: disown: %2: no such job
|
||||
wait-for-non-child
|
||||
./jobs.tests: line 107: wait: pid 1 is not a child of this shell
|
||||
./jobs.tests: line 111: wait: pid 1 is not a child of this shell
|
||||
127
|
||||
3 -- 1 2 3 -- 1 - 2 - 3
|
||||
[1] Running sleep 300 &
|
||||
|
|
@ -64,8 +72,8 @@ running jobs:
|
|||
[1] Running sleep 300 &
|
||||
[2]- Running sleep 350 &
|
||||
[3]+ Running sleep 400 &
|
||||
./jobs.tests: line 123: kill: %4: no such job
|
||||
./jobs.tests: line 125: jobs: %4: no such job
|
||||
./jobs.tests: line 127: kill: %4: no such job
|
||||
./jobs.tests: line 129: jobs: %4: no such job
|
||||
current job:
|
||||
[3]+ Running sleep 400 &
|
||||
previous job:
|
||||
|
|
|
|||
|
|
@ -8,10 +8,14 @@ ${THIS_SH} ./jobs2.sub
|
|||
# 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 $?
|
||||
|
||||
# should be a job-control-not-enabled error
|
||||
# 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
|
||||
|
|
|
|||
22
tests/jobs4.sub
Normal file
22
tests/jobs4.sub
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# test being able to use job control notation in jobs/kill/wait without
|
||||
# job control active, as the SUS requires
|
||||
|
||||
sleep 5 &
|
||||
|
||||
sleep 5 &
|
||||
sleep 5 &
|
||||
sleep 5 &
|
||||
(sleep 5 ; exit 4) &
|
||||
|
||||
jobs
|
||||
|
||||
wait %%
|
||||
echo $?
|
||||
|
||||
wait %1
|
||||
echo $?
|
||||
|
||||
wait
|
||||
|
||||
cat &
|
||||
kill -1 %% && echo i killed it || echo could not kill it
|
||||
|
|
@ -422,7 +422,15 @@ argv[1] = <_QUANTITY-_QUART-_QUEST-_QUILL-_QUOTA-_QUOTE>
|
|||
./new-exp3.sub: line 19: ${!_Q* }: bad substitution
|
||||
./new-exp3.sub: line 24: ${!1*}: bad substitution
|
||||
./new-exp3.sub: line 26: ${!@*}: bad substitution
|
||||
./new-exp.tests: line 503: ${$(($#-1))}: bad substitution
|
||||
Case01---3---A:B:C---
|
||||
Case02---1---A B C::---
|
||||
Case03---3---A:B:C---
|
||||
Case04---3---A:B:C---
|
||||
Case05---3---A:B:C---
|
||||
Case06---1---A B C::---
|
||||
Case07---3---A:B:C---
|
||||
Case08---3---A:B:C---
|
||||
./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
|
|
@ -439,7 +447,7 @@ argv[1] = <a>
|
|||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <>
|
||||
./new-exp.tests: line 522: $(($# - 2)): substring expression < 0
|
||||
./new-exp.tests: line 525: $(($# - 2)): substring expression < 0
|
||||
argv[1] = <bin>
|
||||
argv[2] = <bin>
|
||||
argv[3] = <ucb>
|
||||
|
|
@ -471,4 +479,4 @@ argv[1] = </full/path/to>
|
|||
argv[1] = </>
|
||||
argv[1] = <full/path/to/x16>
|
||||
argv[1] = <x16>
|
||||
./new-exp.tests: line 542: ABXD: parameter unset
|
||||
./new-exp.tests: line 545: ABXD: parameter unset
|
||||
|
|
|
|||
|
|
@ -498,6 +498,9 @@ recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
|
|||
# tests of new prefix expansion ${!prefix*}
|
||||
${THIS_SH} ./new-exp3.sub
|
||||
|
||||
# bug with indirect expansion through bash-2.05b
|
||||
${THIS_SH} ./new-exp4.sub
|
||||
|
||||
# these caused errors and core dumps in versions before bash-2.04
|
||||
c=""
|
||||
echo ${c//${$(($#-1))}/x/}
|
||||
|
|
|
|||
31
tests/new-exp4.sub
Normal file
31
tests/new-exp4.sub
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
arrayA=("A" "B" "C")
|
||||
|
||||
arrayB=( ${arrayA[*]} )
|
||||
echo "Case01---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
|
||||
arrayB=( "${arrayA[*]}" )
|
||||
echo "Case02---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
|
||||
arrayB=( ${arrayA[@]} )
|
||||
echo "Case03---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
|
||||
arrayB=( "${arrayA[@]}" )
|
||||
echo "Case04---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
|
||||
xx="arrayA[*]"
|
||||
|
||||
arrayB=( ${!xx} )
|
||||
echo "Case05---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
|
||||
arrayB=( "${!xx}" )
|
||||
echo "Case06---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
|
||||
xx="arrayA[@]"
|
||||
|
||||
arrayB=( ${!xx} )
|
||||
echo "Case07---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
|
||||
arrayB=( "${!xx}" )
|
||||
echo "Case08---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
|
||||
18
tests/nquote4.right
Normal file
18
tests/nquote4.right
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
argv[1] = <ab>
|
||||
argv[1] = <abAcd>
|
||||
argv[1] = <abAcd>
|
||||
argv[1] = <ab^Dcd>
|
||||
argv[1] = <abLd>
|
||||
argv[1] = <abÞ>
|
||||
argv[1] = <abÞ>
|
||||
argv[1] = <abÍe>
|
||||
argv[1] = <ab^Lde>
|
||||
argv[1] = <¼X>
|
||||
argv[1] = <«cX>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <gX>
|
||||
argv[1] = <Ab>
|
||||
argv[1] = <>
|
||||
argv[1] = <^Abcd>
|
||||
argv[1] = <Þ>
|
||||
24
tests/nquote4.tests
Normal file
24
tests/nquote4.tests
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
recho $'ab\x{}cd'
|
||||
recho $'ab\x{41}cd'
|
||||
recho $'ab\x41cd'
|
||||
|
||||
recho $'ab\x{4}cd'
|
||||
recho $'ab\x4cd'
|
||||
|
||||
recho $'ab\x{cde'
|
||||
|
||||
recho $'ab\x{cde'
|
||||
recho $'ab\x{cd}e'
|
||||
recho $'ab\x{c}de'
|
||||
|
||||
recho $'\x{abcX'
|
||||
recho $'\x{ab}cX'
|
||||
recho $'\x{}X'
|
||||
recho $'\x{X'
|
||||
recho $'\x{01234567X'
|
||||
|
||||
recho $'\x{41}b'
|
||||
recho $'\x{}bc'
|
||||
recho $'\x{1}bcd'
|
||||
|
||||
recho $'\x{bde'
|
||||
Binary file not shown.
|
|
@ -222,3 +222,19 @@ printf $format 0
|
|||
|
||||
# this doesn't work with printf(3) on all systems
|
||||
#printf "%'s\n" foo
|
||||
|
||||
# test cases from an austin-group list discussion
|
||||
# prints ^G as an extension
|
||||
printf '%b\n' '\7'
|
||||
|
||||
# prints ^G
|
||||
printf '%b\n' '\0007'
|
||||
|
||||
# prints NUL then 7
|
||||
printf '\0007\n'
|
||||
|
||||
# prints no more than two hex digits
|
||||
printf '\x07e\n'
|
||||
|
||||
# additional backslash escapes
|
||||
printf '\"\?\n'
|
||||
|
|
|
|||
|
|
@ -49,3 +49,15 @@ while read -u 3 var
|
|||
do
|
||||
echo "$var"
|
||||
done 3<$0
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <:>
|
||||
argv[1] = <:>
|
||||
FOO
|
||||
argv[1] = <>
|
||||
argv[1] = <3>
|
||||
argv[1] = <>
|
||||
argv[2] = <>
|
||||
argv[3] = <>
|
||||
FOO
|
||||
0 0 0
|
||||
|
|
|
|||
|
|
@ -90,3 +90,6 @@ ${THIS_SH} ./read3.sub
|
|||
|
||||
# test read -u fd behavior
|
||||
${THIS_SH} ./read4.sub
|
||||
|
||||
# test behavior when IFS is not the default -- bug through bash-2.05b
|
||||
${THIS_SH} ./read5.sub
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
a=4
|
||||
|
||||
read -t 2 a
|
||||
read -t 2 a < /dev/tty
|
||||
echo $?
|
||||
|
||||
echo $a
|
||||
|
|
@ -10,7 +10,7 @@ echo $?
|
|||
|
||||
echo $a
|
||||
|
||||
read -t -3 a
|
||||
read -t -3 a < /dev/tty
|
||||
echo $?
|
||||
|
||||
echo $a
|
||||
|
|
|
|||
36
tests/read5.sub
Normal file
36
tests/read5.sub
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
IFS=: read x y z << EOF
|
||||
:::
|
||||
EOF
|
||||
recho $x
|
||||
recho "$x"
|
||||
recho $y
|
||||
recho "$y"
|
||||
recho $z
|
||||
recho "$z"
|
||||
|
||||
if [ -z "$x" ]; then
|
||||
echo FOO
|
||||
else
|
||||
echo BAR
|
||||
fi
|
||||
|
||||
IFS=: read -a A << EOF
|
||||
:::
|
||||
EOF
|
||||
|
||||
recho ${A[0]}
|
||||
recho "${A[0]}"
|
||||
|
||||
recho ${#A[@]}
|
||||
|
||||
recho "${A[@]}"
|
||||
|
||||
if [ -z "${A[0]}" ]; then
|
||||
echo FOO
|
||||
else
|
||||
echo BAR
|
||||
fi
|
||||
|
||||
echo -n ${A[0]} | cat -vet
|
||||
echo -n ${A[0]} | wc
|
||||
|
||||
|
|
@ -88,3 +88,9 @@ f ()
|
|||
after read
|
||||
./redir5.sub: line 27: read: read error: 0: Bad file descriptor
|
||||
# tests of ksh93-like dup-and-close redirection operators
|
||||
/
|
||||
/
|
||||
/
|
||||
0
|
||||
0
|
||||
0
|
||||
|
|
|
|||
|
|
@ -153,3 +153,6 @@ cat < redir1.*
|
|||
|
||||
# test ksh93 dup-and-close (move fd) redirections
|
||||
${THIS_SH} ./redir5.sub
|
||||
|
||||
# test behavior after a write error with a builtin command
|
||||
${THIS_SH} ./redir6.sub
|
||||
|
|
|
|||
8
tests/redir6.sub
Normal file
8
tests/redir6.sub
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
cd /
|
||||
pwd
|
||||
help >&-
|
||||
pwd
|
||||
pwd
|
||||
echo $?
|
||||
echo $?
|
||||
echo $?
|
||||
2
tests/run-alias
Normal file
2
tests/run-alias
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
${THIS_SH} ./alias.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx alias.right && rm -f /tmp/xx
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
${THIS_SH} ./braces-tests > /tmp/xx
|
||||
${THIS_SH} ./braces.tests > /tmp/xx
|
||||
diff /tmp/xx braces.right && rm -f /tmp/xx
|
||||
|
|
|
|||
11
tests/run-dbg-support
Executable file
11
tests/run-dbg-support
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!../bash
|
||||
#$Id: run-dbg-support,v 1.5 2002/11/14 06:08:16 rockyb Exp $
|
||||
|
||||
TEST_NAME='dbg-support'
|
||||
TEST_FILE="/tmp/${TEST_NAME}.check"
|
||||
${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null
|
||||
set -f
|
||||
diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
|
||||
|
||||
# Return code tells testing mechanism whether passed or not.
|
||||
exit $?
|
||||
16
tests/run-dbg-support2
Executable file
16
tests/run-dbg-support2
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!../bash
|
||||
#$Id: run-dbg-support2,v 1.3 2002/11/14 06:08:16 rockyb Exp $
|
||||
|
||||
TEST_NAME='dbg-support2'
|
||||
TEST_FILE="/tmp/${TEST_NAME}.check"
|
||||
${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null
|
||||
set -f
|
||||
diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
|
||||
|
||||
# Return code tells testing mechanism whether passed or not.
|
||||
exit $?
|
||||
|
||||
#;;; Local Variables: ***
|
||||
#;;; mode:shell-script ***
|
||||
#;;; eval: (sh-set-shell "bash") ***
|
||||
#;;; End: ***
|
||||
|
|
@ -3,5 +3,7 @@ echo "warning: produce diff output." >&2
|
|||
echo "warning: if the text of the error messages concerning \`notthere' or" >&2
|
||||
echo "warning: \`/tmp/bash-notthere' not being found or \`/' being a directory" >&2
|
||||
echo "warning: produce diff output, please do not consider this a test failure" >&2
|
||||
echo "warning: if diff output differing only in the location of the bash" >&2
|
||||
echo "warning: binary appears, please do not consider this a test failure" >&2
|
||||
${THIS_SH} ./execscript > /tmp/xx 2>&1
|
||||
diff /tmp/xx exec.right && rm -f /tmp/xx
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
PATH=$PATH:`pwd`
|
||||
export PATH
|
||||
${THIS_SH} ./glob-test | grep -v '^expect' > /tmp/xx
|
||||
${THIS_SH} ./glob-test 2>&1 | grep -v '^expect' > /tmp/xx
|
||||
diff /tmp/xx glob.right && rm -f /tmp/xx
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
echo "warning: some of these tests may fail if job control has not been compiled" >&2
|
||||
echo "warning: into the shell" >&2
|
||||
echo "warning: there may be a message regarding a cat process dying due to a" >&2
|
||||
echo "warning: SIGHUP. Please disregard." >&2
|
||||
|
||||
${THIS_SH} ./jobs.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx jobs.right && rm -f /tmp/xx
|
||||
|
|
|
|||
2
tests/run-nquote4
Normal file
2
tests/run-nquote4
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
${THIS_SH} ./nquote.tests 2>&1 | grep -v '^expect' > /tmp/xx
|
||||
diff /tmp/xx nquote.right && rm -f /tmp/xx
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
echo "warning: different versions of wc put differing amounts of whitespace" >&2
|
||||
echo "warning: before their output. Please do not consider this an error." >&2
|
||||
${THIS_SH} ./read.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx read.right && rm -f /tmp/xx
|
||||
|
|
|
|||
11
tests/run-set-x
Executable file
11
tests/run-set-x
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!../bash
|
||||
#$Id: run-set-x,v 1.1 2002/12/09 13:12:37 rockyb Exp $
|
||||
|
||||
TEST_NAME='set-x'
|
||||
TEST_FILE="/tmp/${TEST_NAME}.check"
|
||||
${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null
|
||||
set -f
|
||||
diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
|
||||
|
||||
# Return code tells testing mechanism whether passed or not.
|
||||
exit $?
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
unset GROUPS UID 2>/dev/null
|
||||
|
||||
${THIS_SH} ./test.tests >/tmp/xx 2>&1
|
||||
diff /tmp/xx test.right && rm -f /tmp/xx
|
||||
|
|
|
|||
28
tests/set-x.right
Normal file
28
tests/set-x.right
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
+ (( i=0 ))
|
||||
+ (( i<=5 ))
|
||||
+ x=0
|
||||
+ (( i++ ))
|
||||
+ (( i<=5 ))
|
||||
+ x=0
|
||||
+ (( i++ ))
|
||||
+ (( i<=5 ))
|
||||
+ x=0
|
||||
+ (( i++ ))
|
||||
+ (( i<=5 ))
|
||||
+ x=0
|
||||
+ (( i++ ))
|
||||
+ (( i<=5 ))
|
||||
+ x=0
|
||||
+ (( i++ ))
|
||||
+ (( i<=5 ))
|
||||
+ x=0
|
||||
+ (( i++ ))
|
||||
+ (( i<=5 ))
|
||||
+ for i in 0 1 2
|
||||
+ x=i
|
||||
+ for i in 0 1 2
|
||||
+ x=i
|
||||
+ for i in 0 1 2
|
||||
+ x=i
|
||||
+ case x in
|
||||
+ x=i
|
||||
21
tests/set-x.tests
Executable file
21
tests/set-x.tests
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!../bash
|
||||
# $Id: set-x.tests,v 1.1 2002/12/09 13:12:37 rockyb Exp $
|
||||
#
|
||||
# Test that "set -x" shows what we think it should.
|
||||
#
|
||||
set -x
|
||||
for ((i=0; i<=5; i++ )) ; do
|
||||
x=0
|
||||
done
|
||||
for i in 0 1 2 ; do
|
||||
x=i
|
||||
done
|
||||
case x in
|
||||
0) x=i ;;
|
||||
*) x=i ;;
|
||||
esac
|
||||
|
||||
#;;; Local Variables: ***
|
||||
#;;; mode:shell-script ***
|
||||
#;;; eval: (sh-set-shell "bash") ***
|
||||
#;;; End: ***
|
||||
|
|
@ -9,7 +9,12 @@ shopt -s cmdhist
|
|||
shopt -u dotglob
|
||||
shopt -u execfail
|
||||
shopt -s expand_aliases
|
||||
shopt -u extdebug
|
||||
shopt -u extglob
|
||||
shopt -s extquote
|
||||
shopt -u failglob
|
||||
shopt -s force_fignore
|
||||
shopt -u gnu_errfmt
|
||||
shopt -u histreedit
|
||||
shopt -u histappend
|
||||
shopt -u histverify
|
||||
|
|
@ -36,6 +41,8 @@ shopt -s sourcepath
|
|||
shopt -s cdspell
|
||||
shopt -s cmdhist
|
||||
shopt -s expand_aliases
|
||||
shopt -s extquote
|
||||
shopt -s force_fignore
|
||||
shopt -s hostcomplete
|
||||
shopt -s interactive_comments
|
||||
shopt -s progcomp
|
||||
|
|
@ -47,7 +54,10 @@ shopt -u checkhash
|
|||
shopt -u checkwinsize
|
||||
shopt -u dotglob
|
||||
shopt -u execfail
|
||||
shopt -u extdebug
|
||||
shopt -u extglob
|
||||
shopt -u failglob
|
||||
shopt -u gnu_errfmt
|
||||
shopt -u histreedit
|
||||
shopt -u histappend
|
||||
shopt -u histverify
|
||||
|
|
@ -67,7 +77,10 @@ checkhash off
|
|||
checkwinsize off
|
||||
dotglob off
|
||||
execfail off
|
||||
extdebug off
|
||||
extglob off
|
||||
failglob off
|
||||
gnu_errfmt off
|
||||
histreedit off
|
||||
histappend off
|
||||
histverify off
|
||||
|
|
@ -86,6 +99,8 @@ set +o allexport
|
|||
set -o braceexpand
|
||||
set -o emacs
|
||||
set +o errexit
|
||||
set +o errtrace
|
||||
set +o functrace
|
||||
set -o hashall
|
||||
set -o histexpand
|
||||
set -o history
|
||||
|
|
@ -101,6 +116,7 @@ set +o notify
|
|||
set +o nounset
|
||||
set +o onecmd
|
||||
set +o physical
|
||||
set +o pipefail
|
||||
set +o posix
|
||||
set -o privileged
|
||||
set +o verbose
|
||||
|
|
@ -111,6 +127,8 @@ allexport off
|
|||
braceexpand on
|
||||
emacs on
|
||||
errexit off
|
||||
errtrace off
|
||||
functrace off
|
||||
hashall on
|
||||
histexpand on
|
||||
history on
|
||||
|
|
@ -126,6 +144,7 @@ notify off
|
|||
nounset off
|
||||
onecmd off
|
||||
physical off
|
||||
pipefail off
|
||||
posix off
|
||||
privileged on
|
||||
verbose off
|
||||
|
|
@ -136,6 +155,8 @@ set +o allexport
|
|||
set -o braceexpand
|
||||
set -o emacs
|
||||
set +o errexit
|
||||
set +o errtrace
|
||||
set +o functrace
|
||||
set -o hashall
|
||||
set -o histexpand
|
||||
set -o history
|
||||
|
|
@ -151,6 +172,7 @@ set +o notify
|
|||
set +o nounset
|
||||
set +o onecmd
|
||||
set +o physical
|
||||
set +o pipefail
|
||||
set +o posix
|
||||
set -o privileged
|
||||
set +o verbose
|
||||
|
|
@ -171,6 +193,8 @@ set -o privileged
|
|||
--
|
||||
set +o allexport
|
||||
set +o errexit
|
||||
set +o errtrace
|
||||
set +o functrace
|
||||
set +o ignoreeof
|
||||
set +o keyword
|
||||
set +o noclobber
|
||||
|
|
@ -181,6 +205,7 @@ set +o notify
|
|||
set +o nounset
|
||||
set +o onecmd
|
||||
set +o physical
|
||||
set +o pipefail
|
||||
set +o posix
|
||||
set +o verbose
|
||||
set +o vi
|
||||
|
|
@ -188,6 +213,8 @@ set +o xtrace
|
|||
--
|
||||
allexport off
|
||||
errexit off
|
||||
errtrace off
|
||||
functrace off
|
||||
ignoreeof off
|
||||
keyword off
|
||||
noclobber off
|
||||
|
|
@ -198,6 +225,7 @@ notify off
|
|||
nounset off
|
||||
onecmd off
|
||||
physical off
|
||||
pipefail off
|
||||
posix off
|
||||
verbose off
|
||||
vi off
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ t -s run-all
|
|||
echo 't -t 20'
|
||||
t -t 20
|
||||
echo 't -t 0'
|
||||
t -t 0
|
||||
t -t 0 < /dev/tty
|
||||
|
||||
echo 't -u noexist'
|
||||
t -u noexist
|
||||
|
|
@ -355,7 +355,7 @@ case "${THIS_SH}" in
|
|||
esac
|
||||
|
||||
if ln -s ${SHNAME} /tmp/test.symlink 2>/dev/null; then
|
||||
chgrp ${GROUPS[0]} /tmp/test.symlink
|
||||
chgrp ${GROUPS[0]} /tmp/test.symlink 2>/dev/null
|
||||
echo 't -h /tmp/test.symlink'
|
||||
t -h /tmp/test.symlink
|
||||
# some systems don't let you remove this
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ trap -- 'echo [$LINENO] debug' DEBUG
|
|||
[28] debug
|
||||
./trap.tests[33] debug
|
||||
./trap.tests[34] debug
|
||||
func2[30] debug
|
||||
func2[31] debug
|
||||
func2debug line
|
||||
./trap.tests[36] debug
|
||||
|
|
|
|||
|
|
@ -81,6 +81,6 @@ 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 - SIGINT QUIT TERM
|
||||
|
||||
trap
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ type: usage: type [-afptP] name [name ...]
|
|||
./type.tests: line 13: command: notthere: not found
|
||||
function
|
||||
keyword
|
||||
alias
|
||||
builtin
|
||||
file
|
||||
file
|
||||
|
|
@ -16,7 +15,6 @@ func ()
|
|||
}
|
||||
while is a shell keyword
|
||||
while is a shell keyword
|
||||
m is aliased to `more'
|
||||
builtin is a shell builtin
|
||||
/bin/sh is /bin/sh
|
||||
func
|
||||
|
|
@ -27,6 +25,12 @@ func ()
|
|||
}
|
||||
while
|
||||
while is a shell keyword
|
||||
./type.tests: line 42: type: m: not found
|
||||
./type.tests: line 43: command: m: not found
|
||||
alias m='more'
|
||||
alias m='more'
|
||||
m is aliased to `more'
|
||||
alias
|
||||
alias m='more'
|
||||
alias m='more'
|
||||
alias m='more'
|
||||
|
|
@ -35,8 +39,8 @@ builtin
|
|||
builtin is a shell builtin
|
||||
/bin/sh
|
||||
/bin/sh is /bin/sh
|
||||
./type.tests: line 51: type: func: not found
|
||||
./type.tests: line 53: type: m: not found
|
||||
./type.tests: line 64: type: func: not found
|
||||
./type.tests: line 66: type: m: not found
|
||||
/bin/sh
|
||||
/tmp/bash
|
||||
bash is hashed (/tmp/bash)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ func() { echo this is func; }
|
|||
|
||||
type -t func
|
||||
type -t while
|
||||
type -t m
|
||||
type -t builtin
|
||||
type -t /bin/sh
|
||||
type -t ${THIS_SH}
|
||||
|
|
@ -29,7 +28,6 @@ type func
|
|||
# the following two should produce identical output
|
||||
type while
|
||||
type -a while
|
||||
type m
|
||||
type builtin
|
||||
type /bin/sh
|
||||
|
||||
|
|
@ -37,11 +35,26 @@ command -v func
|
|||
command -V func
|
||||
command -v while
|
||||
command -V while
|
||||
|
||||
# the following three lines should produce the same output
|
||||
# first test with alias expansion off (should all fail or produce no output)
|
||||
type -t m
|
||||
type m
|
||||
command -v m
|
||||
alias -p
|
||||
alias m
|
||||
|
||||
# then test with alias expansion on
|
||||
shopt -s expand_aliases
|
||||
type m
|
||||
type -t m
|
||||
command -v m
|
||||
alias -p
|
||||
alias m
|
||||
|
||||
command -V m
|
||||
shopt -u expand_aliases
|
||||
|
||||
command -v builtin
|
||||
command -V builtin
|
||||
command -v /bin/sh
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ unset
|
|||
declare -x ivar="42"
|
||||
hB
|
||||
braceexpand:hashall:interactive-comments
|
||||
hPB
|
||||
hBP
|
||||
braceexpand:hashall:interactive-comments:physical
|
||||
declare -r SHELLOPTS="braceexpand:hashall:interactive-comments:physical"
|
||||
abcde
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue