Bash-5.3-alpha release

This commit is contained in:
Chet Ramey
2024-04-22 10:33:38 -04:00
parent f3b6bd1945
commit 622d318652
700 changed files with 136534 additions and 96420 deletions
+19
View File
@@ -1,8 +1,12 @@
alias: 0
alias: 0
./alias.tests: line 38: qfoo: command not found
./alias.tests: line 44: unalias: foo: not found
quux
hi
declare -a m=([0]="x")
./alias.tests: line 66: alias: `\$': invalid alias name
./alias.tests: line 67: `\$': invalid alias name
bar
value
bar
@@ -31,6 +35,7 @@ a b
a a b
ok 3
ok 4
line with escaped newline
bar
bad
0
@@ -43,3 +48,17 @@ bar
baz
<áa>
<aá>
bar
foo bar x
foo
x
bar
x
bar
x
foo=v bar=
foo
foo in v
bash: -c: line 7: syntax error near unexpected token `do'
bash: -c: line 7: `do echo foo=$foo bar=$bar'
foo=v bar=
+11 -1
View File
@@ -40,6 +40,8 @@ qfoo
unalias qfoo qbar qbaz quux
unalias -a
# error
unalias foo
alias foo='echo '
alias bar=baz
@@ -54,12 +56,20 @@ unalias foo bar baz
alias foo='a=() b=""
for i in 1; do echo hi; done'
foo
unalias foo
alias L='m=("x")'
L
declare -p m
# invalid alias names generate errors
alias '\$'=xx
BASH_ALIASES['\$']=xx
${THIS_SH} ./alias1.sub
${THIS_SH} ./alias2.sub
${THIS_SH} ./alias3.sub
${THIS_SH} ./alias4.sub
${THIS_SH} ./alias5.sub
${THIS_SH} ./alias6.sub
${THIS_SH} ./alias7.sub
+7
View File
@@ -82,6 +82,12 @@ long_comment text after
# comment
comment foo bar
# make sure escaped newlines in alias bodies are processed correctly
alias xx='echo line with \
escaped newline'
xx
unalias xx
# alias ending in a tab
alias foo="\
echo \"bar\" \
@@ -98,3 +104,4 @@ foo>&2
alias a='printf "<%s>\n" \'
a|cat
+10
View File
@@ -84,3 +84,13 @@ bash: -c: line 1: syntax error: `(( i=0; i < 3; i++; 7 ))'
2
1
0
43210
ok1
./arith-for.tests: line 133: ((: 7++ : arithmetic syntax error: operand expected (error token is "+ ")
./arith-for.tests: line 134: ((: i < 4/0: division by 0 (error token is "0")
./arith-for.tests: line 135: ((: i=2/0: division by 0 (error token is "0")
./arith-for.tests: line 137: ((: 7=4 : attempted assignment to non-variable (error token is "=4 ")
./arith-for.tests: line 139: ((: j=: arithmetic syntax error: operand expected (error token is "=")
X
./arith-for.tests: line 141: break: only meaningful in a `for', `while', or `until' loop
Y
+14
View File
@@ -126,3 +126,17 @@ echo
for (( i = 4; ;i--)) ; do echo $i; if (( $i == 0 )); then break; fi; done
for (( i = 4;;i--)) ; do echo $i; if (( $i == 0 )); then break; fi; done
i=4 ; for (( ;;i--)) ; do echo -n $i; if (( i == 0 )); then break; fi; done; echo
# arithmetic for commands with expression errors
for (( i=1; i < 4; 7++ )); do echo ok$i ; done
for (( i=2; i < 4/0; 7++ )); do echo whoops1 ; done
for (( i=2/0; i < 4; 7++ )); do echo whoops2 ; done
for (( 7=4 ; 7 > 7; )); do echo whoops3; done
for ((j=;;)); do :; done
echo X
break
echo Y
+67 -35
View File
@@ -51,6 +51,7 @@
1
1
32
32
4
20
1,i+=2
@@ -60,7 +61,7 @@
1,i+=2
30
1,j+=2
./arith.tests: line 127: 1 ? 20 : x+=2: attempted assignment to non-variable (error token is "+=2")
./arith.tests: line 129: 1 ? 20 : x+=2: attempted assignment to non-variable (error token is "+=2")
20
6
6,5,3
@@ -70,6 +71,8 @@
127
36
40
40
40
10
10
10
@@ -80,16 +83,18 @@
36
62
63
./arith.tests: line 162: 3425#56: invalid arithmetic base (error token is "3425#56")
./arith.tests: line 165: 2#: invalid integer constant (error token is "2#")
./arith.tests: line 168: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
./arith.tests: line 169: 2#44: value too great for base (error token is "2#44")
./arith.tests: line 170: 44 / 0 : division by 0 (error token is "0 ")
./arith.tests: line 171: let: jv += $iv: syntax error: operand expected (error token is "$iv")
./arith.tests: line 172: jv += $iv : syntax error: operand expected (error token is "$iv ")
./arith.tests: line 173: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
./arith.tests: line 177: 0#4: invalid number (error token is "0#4")
./arith.tests: line 178: 2#110#11: invalid number (error token is "2#110#11")
./arith.tests: line 168: 3425#56: invalid arithmetic base (error token is "3425#56")
./arith.tests: line 171: 2#: invalid integer constant (error token is "2#")
./arith.tests: line 174: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
./arith.tests: line 175: 2#44: value too great for base (error token is "2#44")
./arith.tests: line 176: 44 / 0 : division by 0 (error token is "0 ")
./arith.tests: line 177: let: jv += $iv: arithmetic syntax error: operand expected (error token is "$iv")
./arith.tests: line 178: jv += $iv : arithmetic syntax error: operand expected (error token is "$iv ")
./arith.tests: line 179: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
./arith.tests: line 182: b / 0 : division by 0 (error token is "0 ")
./arith.tests: line 183: b /= 0 : division by 0 (error token is "0 ")
./arith.tests: line 188: 0#4: invalid number (error token is "0#4")
./arith.tests: line 189: 2#110#11: invalid number (error token is "2#110#11")
abc
def
ghi
@@ -97,15 +102,15 @@ ok
6
1
0
./arith.tests: line 196: 4 + : syntax error: operand expected (error token is "+ ")
./arith.tests: line 207: 4 + : arithmetic syntax error: operand expected (error token is "+ ")
16
./arith.tests: line 201: 4 ? : 3 + 5 : expression expected (error token is ": 3 + 5 ")
./arith.tests: line 202: 1 ? 20 : `:' expected for conditional expression (error token is "20 ")
./arith.tests: line 203: 4 ? 20 : : expression expected (error token is ": ")
./arith.tests: line 212: 4 ? : 3 + 5 : expression expected (error token is ": 3 + 5 ")
./arith.tests: line 213: 1 ? 20 : `:' expected for conditional expression (error token is "20 ")
./arith.tests: line 214: 4 ? 20 : : expression expected (error token is ": ")
9
./arith.tests: line 209: 0 && B=42 : attempted assignment to non-variable (error token is "=42 ")
./arith.tests: line 220: 0 && B=42 : attempted assignment to non-variable (error token is "=42 ")
9
./arith.tests: line 212: 1 || B=88 : attempted assignment to non-variable (error token is "=88 ")
./arith.tests: line 223: 1 || B=88 : attempted assignment to non-variable (error token is "=88 ")
9
0
9
@@ -121,6 +126,7 @@ ok
131072
2147483647
1
./arith.tests: line 255: 2**-1 : exponent less than 0 (error token is "1 ")
4
4
5
@@ -131,22 +137,23 @@ ok
4
4
7
./arith.tests: line 260: 7-- : syntax error: operand expected (error token is "- ")
./arith.tests: line 262: --x=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: line 263: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: line 265: x++=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: line 266: x--=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: line 274: 7-- : arithmetic syntax error: operand expected (error token is "- ")
./arith.tests: line 276: --x=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: line 277: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: line 279: x++=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: line 280: x--=7 : attempted assignment to non-variable (error token is "=7 ")
4
7
-7
7
7
./arith.tests: line 292: --x++ : ++: assignment requires lvalue (error token is "++ ")
2
2
./arith1.sub: line 15: 4-- : syntax error: operand expected (error token is "- ")
./arith1.sub: line 16: 4++ : syntax error: operand expected (error token is "+ ")
./arith1.sub: line 17: 4 -- : syntax error: operand expected (error token is "- ")
./arith1.sub: line 18: 4 ++ : syntax error: operand expected (error token is "+ ")
./arith1.sub: line 15: 4-- : arithmetic syntax error: operand expected (error token is "- ")
./arith1.sub: line 16: 4++ : arithmetic syntax error: operand expected (error token is "+ ")
./arith1.sub: line 17: 4 -- : arithmetic syntax error: operand expected (error token is "- ")
./arith1.sub: line 18: 4 ++ : arithmetic syntax error: operand expected (error token is "+ ")
1
2
1
@@ -161,10 +168,10 @@ ok
2
-2
1
./arith1.sub: line 48: ((: ++ : syntax error: operand expected (error token is "+ ")
./arith1.sub: line 48: ((: ++ : arithmetic syntax error: operand expected (error token is "+ ")
7
7
./arith1.sub: line 51: ((: -- : syntax error: operand expected (error token is "- ")
./arith1.sub: line 51: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
7
7
7
@@ -183,10 +190,10 @@ ok
1
4
0
./arith2.sub: line 46: ((: -- : syntax error: operand expected (error token is "- ")
./arith2.sub: line 46: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
-7
-7
./arith2.sub: line 50: ((: ++ : syntax error: operand expected (error token is "+ ")
./arith2.sub: line 50: ((: ++ : arithmetic syntax error: operand expected (error token is "+ ")
7
7
-7
@@ -249,15 +256,40 @@ efg
0
0
0
./arith9.sub: line 4: a: unbound variable
./arith9.sub: line 5: a: unbound variable
0
after 3 0
0
after 4 0
./arith9.sub: line 14: b: expression recursion level exceeded (error token is "b")
+ var=42
+ echo 42
42
+ echo 0
0
+ echo 0
0
+ echo 0
0
+ (( 42 ))
+ echo 0
0
+ (( ))
+ echo 1
1
+ set +x
./arith9.sub: line 37: 4+: arithmetic syntax error: operand expected (error token is "+")
x = 4+ y =
8 12
./arith.tests: line 310: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
./arith.tests: line 314: a b: syntax error in expression (error token is "b")
./arith.tests: line 315: ((: a b: syntax error in expression (error token is "b")
./arith.tests: line 332: ((: x=9 y=41 : arithmetic syntax error in expression (error token is "y=41 ")
./arith.tests: line 336: a b: arithmetic syntax error in expression (error token is "b")
./arith.tests: line 337: ((: a b: arithmetic syntax error in expression (error token is "b")
42
42
42
42
42
42
./arith.tests: line 330: 'foo' : syntax error: operand expected (error token is "'foo' ")
./arith.tests: line 333: b[c]d: syntax error in expression (error token is "d")
./arith.tests: line 352: 'foo' : arithmetic syntax error: operand expected (error token is "'foo' ")
./arith.tests: line 355: b[c]d: arithmetic syntax error in expression (error token is "d")
+22
View File
@@ -97,6 +97,8 @@ echo $(( 4<(2+3) ? 1 : 32))
echo $(( (2+2)<(2+3) ? 1 : 32))
echo $(( (2+2)>(2+3) ? 1 : 32))
echo $(( (2+2)>(2+3) ? 2**0 : 32))
# bug in bash versions through bash-3.2
S=105
W=$((S>99?4:S>9?3:S>0?2:0))
@@ -143,6 +145,10 @@ echo $(( 16#FF/2 ))
echo $(( 8#44 ))
echo $(( 8 ^ 32 ))
a=8
echo $(( a ^ 32 ))
echo $(( a ^= 32 ))
unset -v a
# other bases
echo $(( 16#a ))
@@ -172,6 +178,11 @@ let 'jv += $iv'
echo $(( jv += \$iv ))
let 'rv = 7 + (43 * 6'
b=44
echo $(( b / 0 ))
echo $(( b /= 0 ))
unset -v b
# more errors
declare -i i
i=0#4
@@ -240,6 +251,9 @@ echo $(( 2**16*2 ))
echo $(( 2**31-1))
echo $(( 2**0 ))
# error
echo $(( 2**-1 ))
# {pre,post}-{inc,dec}rement and associated errors
x=4
@@ -273,6 +287,11 @@ echo $(( -7 ))
echo $(( ++7 ))
echo $(( --7 ))
unset -v x
x=8
echo $(( --x++ )) # error
unset -v x
# combinations of expansions
echo $(( "`echo 1+1`" ))
echo $(( `echo 1+1` ))
@@ -299,6 +318,9 @@ ${THIS_SH} ./arith7.sub
# problems with evaluation of conditional expressions
${THIS_SH} ./arith8.sub
# expressions with unset variables and nounset enabled
${THIS_SH} ./arith9.sub
x=4
y=7
+96 -31
View File
@@ -1,6 +1,6 @@
./array.tests: line 28: syntax error near unexpected token `&'
./array.tests: line 28: `test=(first & second)'
./array.tests: line 34: syntax error near unexpected token `&'
./array.tests: line 34: `test=(first & second)'
1
abcde
abcde
@@ -26,7 +26,7 @@ hello world
11
3
bdef hello world test expression test 2
./array.tests: line 92: readonly: `a[5]': not a valid identifier
./array.tests: line 98: readonly: `a[5]': not a valid identifier
declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
declare -ar c
declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
@@ -46,17 +46,17 @@ declare -ar c
declare -a d=([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")
declare -a e=([0]="test")
declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
./array.tests: line 116: a: readonly variable
./array.tests: line 118: b[]: bad array subscript
./array.tests: line 119: b[*]: bad array subscript
./array.tests: line 122: a: readonly variable
./array.tests: line 124: b[]: bad array subscript
./array.tests: line 125: b[*]: bad array subscript
this
./array.tests: line 122: c[-2]: bad array subscript
./array.tests: line 123: c: bad array subscript
./array.tests: line 128: c[-2]: bad array subscript
./array.tests: line 129: c: bad array subscript
./array.tests: line 125: d[7]: cannot assign list to array member
./array.tests: line 127: []=abcde: bad array subscript
./array.tests: line 127: [*]=last: cannot assign to non-numeric index
./array.tests: line 127: [-65]=negative: bad array subscript
./array.tests: line 131: d[7]: cannot assign list to array member
./array.tests: line 133: []=abcde: bad array subscript
./array.tests: line 134: [*]=last: cannot assign to non-numeric index
./array.tests: line 135: [-65]=negative: bad array subscript
declare -a BASH_ARGC=()
declare -a BASH_ARGV=()
declare -a BASH_LINENO=([0]="0")
@@ -69,8 +69,8 @@ declare -ar c
declare -a d=([1]="test test")
declare -a e=()
declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
./array.tests: line 135: unset: ps1: not an array variable
./array.tests: line 139: declare: c: cannot destroy array variables in this way
./array.tests: line 143: unset: ps1: not an array variable
./array.tests: line 147: declare: c: readonly variable
this of
this is a test of read using arrays
this test
@@ -123,13 +123,17 @@ argv[1] = </>
55
49
6 -- 6
./array.tests: line 238: [-10]: bad array subscript
0
42 14 44
grep [ 123 ] *
6 7 9
6 7 9 5
length = 3
value = new1 new2 new3
./array.tests: line 255: narray: unbound variable
./array.tests: line 267: syntax error near unexpected token `&'
./array.tests: line 267: `badarray=( metacharacters like & need to be quoted in compound assignments)'
./array.tests: line 271: narray: unbound variable
./array1.sub: line 1: syntax error near unexpected token `('
./array1.sub: line 1: `printf "%s\n" -a a=(a 'b c')'
./array2.sub: line 1: declare: `[]=asdf': not a valid identifier
@@ -156,10 +160,10 @@ for case if then else
12 14 16 18 20
4414758999202
aaa bbb
./array.tests: line 305: syntax error near unexpected token `<>'
./array.tests: line 305: `metas=( <> < > ! )'
./array.tests: line 306: syntax error near unexpected token `<>'
./array.tests: line 306: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
./array.tests: line 321: syntax error near unexpected token `<>'
./array.tests: line 321: `metas=( <> < > ! )'
./array.tests: line 322: syntax error near unexpected token `<>'
./array.tests: line 322: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
abc 3
case 4
abc case if then else 5
@@ -206,6 +210,13 @@ e
b c
$0
declare -a A=([0]="X=a" [1]="b")
2 3 4 5 6
FIN1:0
FIN2:0
FIN3:0
FIN4:0
FIN5:0
FIN6:0
t
[3]=abcde r s t u v
e
@@ -393,6 +404,10 @@ bar: array with element zero unset: ok
bar: element zero: ok
qux: unset array: ok
qux: unset array element 0: ok
1
0
0
0
2
2
2
@@ -400,7 +415,7 @@ qux: unset array element 0: ok
0
0
1
./array17.sub: line 43: ~: syntax error: operand expected (error token is "~")
./array17.sub: line 43: ~: arithmetic syntax error: operand expected (error token is "~")
0
0
3
@@ -415,7 +430,7 @@ one
one
two
two
./array17.sub: line 89: ~ : syntax error: operand expected (error token is "~ ")
./array17.sub: line 89: ~ : arithmetic syntax error: operand expected (error token is "~ ")
1
argv[1] = <>
argv[2] = <>
@@ -453,7 +468,7 @@ declare -A a=([1]="b" [0]="a" )
declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
declare -a var=([0]="[\$(echo total 0)]=1 [2]=2]")
declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
./array19.sub: line 89: total 0: syntax error in expression (error token is "0")
./array19.sub: line 89: total 0: arithmetic syntax error in expression (error token is "0")
declare -a var=()
declare -al foo=([0]="abcde" [1]="two" [2]="three")
declare -al foo=([0]="abcde")
@@ -522,14 +537,14 @@ p3
argv[1] = <y>
<X> <X> <X> <X>
<X> <X> <X> <X>
./array23.sub: line 22: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 23: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 24: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 26: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 30: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )")
./array23.sub: line 33: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )")
./array23.sub: line 34: $index: syntax error: operand expected (error token is "$index")
./array23.sub: line 35: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )")
./array23.sub: line 22: $( echo >&2 foo ) : arithmetic syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 23: $( echo >&2 foo ) : arithmetic syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 24: $( echo >&2 foo ) : arithmetic syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 26: $( echo >&2 foo ) : arithmetic syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 30: $( echo >&2 foo ): arithmetic syntax error: operand expected (error token is "$( echo >&2 foo )")
./array23.sub: line 33: $( echo >&2 foo ): arithmetic syntax error: operand expected (error token is "$( echo >&2 foo )")
./array23.sub: line 34: $index: arithmetic syntax error: operand expected (error token is "$index")
./array23.sub: line 35: $( echo >&2 foo ): arithmetic syntax error: operand expected (error token is "$( echo >&2 foo )")
0
0
0
@@ -583,7 +598,7 @@ jkl
1. indexed:
reference:
1. 0
./array25.sub: line 24: ' ': syntax error: operand expected (error token is "' '")
./array25.sub: line 24: ' ': arithmetic syntax error: operand expected (error token is "' '")
3. 0
4. 0
5. 0
@@ -757,6 +772,8 @@ declare -A A=([$'\t']="X" ["*"]="X" [" "]="X" ["@"]="X" )
declare -A A=(["*"]="X" ["@"]="X" )
./array27.sub: line 76: declare: `A[]]=X': not a valid identifier
declare -A A=(["*"]="X" ["@"]="X" )
./array27.sub: line 81: y[]: bad array subscript
./array27.sub: line 81: y[]: bad array subscript
declare -a bug4=([0]="" [1]="5" [2]="" [3]="1" [4]="")
declare -a bug=([0]="" [1]="5" [2]="" [3]="1" [4]="")
declare -a bug2=([0]="")
@@ -785,3 +802,51 @@ FOO
declare -Au A=([Darwin]="FOO" )
FOO
declare -Au A=(["@"]="FOO" )
declare -a aa=([0]="/homes/cj/Desktop")
declare -a aa=([0]="/homes/cj/Desktop")
declare -a aa=([0]="/homes/cj/Desktop:/homes/cj/Library:/homes/cj/Documents")
declare -a aa=([0]="/homes/cj/Desktop:/homes/cj/Library:/homes/cj/Documents")
declare -a aa=([0]="/homes/cj/Desktop:/homes/cj/Library:/homes/cj/Documents" [1]="/homes/cj/Applications")
declare -a aa=([0]="/homes/cj/Desktop:/homes/cj/Library:/homes/cj/Documents" [1]="/homes/cj/Applications")
./array32.sub: line 20: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
./array32.sub: line 21: declare: a: not found
./array32.sub: line 24: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
./array32.sub: line 25: declare: a: not found
./array32.sub: line 29: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a=([0]="hi")
./array32.sub: line 35: declare: a: not found
./array32.sub: line 38: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
./array32.sub: line 39: declare: a: not found
./array32.sub: line 42: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a
./array32.sub: line 50: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a
./array32.sub: line 57: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -ai a
./array32.sub: line 65: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
./array32.sub: line 66: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
./array32.sub: line 68: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
./array32.sub: line 75: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a
./array32.sub: line 77: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a
./array32.sub: line 80: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a
./array32.sub: line 85: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
./array32.sub: line 91: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a=()
./array32.sub: line 95: $(echo INJECTION! >&2 ; echo 0): arithmetic syntax error: operand expected (error token is "$(echo INJECTION! >&2 ; echo 0)")
declare -a a=()
declare -A A=([x]="x" )
declare -A A=([1]="1" )
./array33.sub: line 27: f: A: cannot convert associative to indexed array
./array33.sub: line 27: declare: A: cannot convert associative to indexed array
./array33.sub: line 31: A: cannot convert associative to indexed array
declare -A A=([1]="1" )
declare -a A=([0]="x" [1]="x")
./array33.sub: line 40: f: A: cannot convert indexed to associative array
./array33.sub: line 40: declare: A: cannot convert indexed to associative array
declare -a A=([0]="x" [1]="x")
./array33.sub: line 46: A: cannot convert indexed to associative array
declare -a A=([0]="x" [1]="x")
./array33.sub: line 52: read: A: not an indexed array
+40 -9
View File
@@ -11,13 +11,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Filter stdin to remove builtin array variables that are
# automatically set and possibly contain values that vary.
ignore_builtin_arrays()
{
grep -v -e BASH_VERSINFO= -e PIPESTATUS= -e GROUPS=
}
# this is needed so that the bad assignments (b[]=bcde, for example) do not
# cause fatal shell errors when in posix mode
set +o posix
set +a
# The calls to egrep -v are to filter out builtin array variables that are
# automatically set and possibly contain values that vary.
# first make sure we handle the basics
x=()
@@ -61,7 +67,7 @@ echo ${a[@]}
echo ${a[*]}
# this should print out values, too
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
declare -a | ignore_builtin_arrays
unset a[7]
echo ${a[*]}
@@ -92,11 +98,11 @@ echo ${a[@]}
readonly a[5]
readonly a
# these two lines should output `declare' commands
readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
declare -ar | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
readonly -a | ignore_builtin_arrays
declare -ar | ignore_builtin_arrays
# this line should output `readonly' commands, even for arrays
set -o posix
readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
readonly -a | ignore_builtin_arrays
set +o posix
declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")'
@@ -111,7 +117,7 @@ b=([0]=this [1]=is [2]=a [3]=test [4]="$PS1" [5]=$pass)
echo ${b[@]:2:3}
declare -pa | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
declare -pa | ignore_builtin_arrays
a[3]="this is a test"
@@ -125,11 +131,13 @@ echo ${c[-4]}
d[7]=(abdedfegeee)
d=([]=abcde [1]="test test" [*]=last [-65]=negative )
d=([0]=abcde [1]="test test" [*]=last )
d=([1]="test test" [-65]=negative )
unset d[12]
unset e[*]
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
declare -a | ignore_builtin_arrays
ps1='hello'
unset ps1[2]
@@ -155,7 +163,7 @@ echo ${vv[0]} ${vv[3]}
echo ${vv[@]}
unset vv
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
declare -a | ignore_builtin_arrays
export rv
#set
@@ -226,6 +234,11 @@ unset xpath[nelem-1]
nelem=${#xpath[@]}
echo ${#xpath[@]} -- $nelem
# error
echo ${#xpath[-10]}
# zero length for unset elements
echo ${#xpath[42]}
# arrays and things that look like index assignments
array=(42 [1]=14 [2]=44)
@@ -250,6 +263,9 @@ barray=(new1 new2 new3)
echo "length = ${#barray[@]}"
echo "value = ${barray[*]}"
# the compound assignment syntax inherited from ksh93 has some quirks
badarray=( metacharacters like & need to be quoted in compound assignments)
# make sure the array code behaves correctly with respect to unset variables
set -u
( echo ${#narray[4]} )
@@ -397,6 +413,18 @@ Z='a b'
A=( X=$Z )
declare -p A
# combine with brace expansion
letters=( {0..9} )
echo "${letters["{2..6}"]}"
# tests for assigning to noassign array variables
BASH_ARGC=(xxx) ; echo FIN1:$?
BASH_ARGC=foio ; echo FIN2:$?
declare BASH_ARGC=(xxx) ; echo FIN3:$?
declare BASH_ARGC=foio ; echo FIN4:$?
BASH_ARGV[1]=foo ; echo FIN5:$?
declare BASH_ARGV[1]=foo ; echo FIN6:$?
# tests for bash-3.1 problems
${THIS_SH} ./array5.sub
@@ -427,3 +455,6 @@ ${THIS_SH} ./array27.sub
${THIS_SH} ./array28.sub
${THIS_SH} ./array29.sub
${THIS_SH} ./array30.sub
${THIS_SH} ./array31.sub
${THIS_SH} ./array32.sub
${THIS_SH} ./array33.sub
+9
View File
@@ -32,3 +32,12 @@ bar[1]=set
typeset -a qux
[[ -v qux ]] || echo qux: unset array: ok
[[ -v qux[0] ]] || echo qux: unset array element 0: ok
unset -v a
a[1]=set
[[ -v a ]] ; echo $?
[[ -v a[1] ]] ; echo $?
[[ -v a[@] ]] ; echo $?
[[ ${#a[@]} > 0 ]]; echo $?
+3
View File
@@ -76,3 +76,6 @@ for k in ']' '*' '@'; do
declare "A[$k]=X"
done
declare -p A
# empty arrays in arith contexts
(( y[$none] ))
+10 -1
View File
@@ -40,6 +40,8 @@ argv[2] = <qix>
argv[1] = <qux qix>
declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
argv[1] = <2>
./assoc.tests: line 99: [$unset]: bad array subscript
0
argv[1] = <7>
argv[1] = <qux>
argv[2] = <qix>
@@ -283,7 +285,7 @@ declare -A assoc=(["*"]="star" ["!"]="bang" ["@"]="at" )
at
star
declare -A a=(["@"]="at" )
./assoc13.sub: line 22: ia[@]: bad array subscript
./assoc13.sub: line 35: ia[@]: bad array subscript
declare -a ia
declare -A a=(["@"]="at2" )
declare -A a=(["@"]=" string" )
@@ -398,3 +400,10 @@ declare -A A=()
declare -A A=(["]"]="rbracket" ["["]="lbracket" )
declare -A A=()
5: ok 1
declare -A aa=([key]="/homes/cj/Desktop" )
declare -A aa=([key]="/homes/cj/Desktop" )
declare -A aa=([k2]="/homes/cj/Library" [key]="/homes/cj/Desktop" )
declare -A aa=([/homes/cj/key]="/homes/cj/Desktop" )
declare -A aa=([/homes/cj/Documents]="/homes/cj/Library" [/homes/cj/key]="/homes/cj/Desktop" )
declare -A aa=([/homes/cj/Documents]="/homes/cj/Library" [/homes/cj/key]="/homes/cj/Desktop:/homes/cj/Documents:/homes/cj/Applications" )
declare -A aa=([/homes/cj/Documents]="/homes/cj/Library" [/homes/cj/key]="/homes/cj/Desktop:/homes/cj/Documents:/homes/cj/Applications" )
+7
View File
@@ -95,6 +95,11 @@ wheat=([six]=6 [foo bar]="qux qix" )
recho ${#wheat[@]}
# and error
echo ${#wheat[$unset]}
# zero length for unset element
echo ${#wheat[unset]}
recho ${#wheat[foo bar]}
# TEST - appending assignment operator
@@ -266,3 +271,5 @@ ${THIS_SH} ./assoc17.sub
# tests with `[' and `]' subscripts and printf/read/wait builtins
${THIS_SH} ./assoc18.sub
# tests with tilde expansion in keys and values post-bash-5.2
${THIS_SH} ./assoc19.sub
+13 -1
View File
@@ -1,3 +1,16 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# assignment to @ and *
declare -A assoc
@@ -41,4 +54,3 @@ declare a[*]=star2
declare -p a
unset a
+2 -2
View File
@@ -1,5 +1,5 @@
after f1:declare -ar a=([0]="1")
./attr.tests: line 17: a: readonly variable
./attr.tests: line 17: f2: a: readonly variable
after f2:declare -ar a=([0]="1")
./attr.tests: line 18: a: readonly variable
after f3:declare -ar a=([0]="1")
@@ -17,7 +17,7 @@ declare -r p="1"
declare -ar r=([0]="1")
./attr1.sub: line 36: r: readonly variable
declare -ar r=([0]="1")
./attr1.sub: line 40: r: readonly variable
./attr1.sub: line 40: f: r: readonly variable
declare -ar r=([0]="1")
./attr1.sub: line 44: readonly: r: readonly variable
declare -ar r=([0]="1")
+7
View File
@@ -22,6 +22,11 @@ foobar foobaz
bazx bazy
vx vy
bazx bazy
4
4
./braces.tests: command substitution: line 59: unexpected EOF while looking for matching `)'
4
4
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
@@ -58,6 +63,8 @@ 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 c e g i k m o q s u w y
z x v t r p n l j h f d b
2147483645 2147483646 2147483647 2147483648 2147483649
00 01 02 03 04 05 06 07 08 09 10
00 02 04 06 08 10
10 8 6 4 2 0
10 8 6 4 2 0
-50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0
+15
View File
@@ -49,6 +49,17 @@ echo ${var}{x,y}
unset var varx vary
# make sure ${ is parsed as a word expansion, since it may contain other
# expansions
a=4
echo "${a#'$('\'}"
echo "${a-'$('\'}"
echo "${a+'$('\'}"
echo "${a#aaaa'$(aaaa'aaa)aaa\'}"
echo "${a#aaaa'$(aaaa)'aaaa\'}"
unset -v a
# new sequence brace operators
echo {1..10}
@@ -110,6 +121,10 @@ echo {z..a..-2}
# make sure brace expansion handles ints > 2**31 - 1 using intmax_t
echo {2147483645..2147483649}
# want zero-padding here
echo {00..10}
echo {00..10..2}
# unwanted zero-padding -- fixed post-bash-4.0
echo {10..0..2}
echo {10..0..-2}
+216 -4
View File
@@ -1,4 +1,3 @@
1000
a
end-1
a
@@ -84,13 +83,17 @@ enable times
enable trap
enable unset
enable -n test worked
enable -n test
enable test worked
./builtins.tests: line 126: enable: notbuiltin: not a shell builtin
./builtins.tests: line 127: enable: test: not dynamically loaded
specialname
-specialname
FOO=BAR
FOO=BAR
hash: hash table empty
0
no-newline
AVAR
foo
in source.sub2, calling return
@@ -106,6 +109,7 @@ m n o p
/tmp/bash-dir-a
/tmp/bash-dir-a
/tmp/bash-dir-a
/
./source5.sub: line 23: /tmp/source-notthere: No such file or directory
after bad source 1
./source5.sub: line 30: /tmp/source-notthere: No such file or directory
@@ -145,17 +149,19 @@ AVAR
foo
declare -x foo=""
declare -x FOO="\$\$"
./builtins.tests: line 228: declare: FOO: not found
./builtins.tests: line 239: declare: FOO: not found
declare -x FOO="\$\$"
ok
ok
./builtins.tests: line 260: kill: 4096: invalid signal specification
./builtins.tests: line 271: kill: 4096: invalid signal specification
1
a\n\n\nb
a
b
-p
a b c
before: f = 4
inside
after: f = 8 bar = 4
@@ -278,4 +284,210 @@ type
+ command -p -- command -v type
type
+ set +x
./builtins.tests: line 284: exit: status: numeric argument required
u=rw,g=rx,o=rx
u=r,g=rx,o=rx
u=rwx,g=rwx,o=
u=rw,g=wx,o=rx
u=rx,g=rx,o=rx
u=rwx,g=rx,o=rwx
u=rwx,g=rwx,o=rx
u=rx,g=rx,o=rx
u=rwx,g=rx,o=rx
u=rwx,g=rwx,o=rwx
u=rwx,g=rwx,o=rwx
u=rwx,g=rx,o=rx
u=rwx,g=rx,o=rx
u=rwx,g=rx,o=rx
u=rwx,g=rx,o=rx
u=rwx,g=rx,o=rx
u=rwx,g=rx,o=rx
u=rwx,g=rx,o=x
hash: hash table empty
./builtins9.sub: line 19: hash: notthere: not found
1
/nosuchdir/nosuchfile
builtin hash -p /nosuchdir/nosuchfile cat
builtin hash -p /nosuchdir/nosuchfile cat
./builtins9.sub: line 30: hash: notthere: not found
./builtins9.sub: line 32: hash: notthere: not found
./builtins9.sub: line 33: hash: notthere: not found
1
./builtins9.sub: line 40: /nosuchdir/nosuchfile: No such file or directory
127
/nosuchdir/nosuchfile
0
0
found
./builtins9.sub: line 52: hash: /: Is a directory
builtin hash -p /nosuchfile cat
./builtins10.sub: line 17: help: -x: invalid option
help: usage: help [-dms] [pattern ...]
These shell commands are defined internally. Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
! PIPELINE history [-c] [-d offset] [n] or hist>
job_spec [&] if COMMANDS; then COMMANDS; [ elif C>
(( expression )) jobs [-lnprs] [jobspec ...] or jobs >
. filename [arguments] kill [-s sigspec | -n signum | -sigs>
: let arg [arg ...]
[ arg... ] local [option] name[=value] ...
[[ expression ]] logout [n]
alias [-p] [name[=value] ... ] mapfile [-d delim] [-n count] [-O or>
bg [job_spec ...] popd [-n] [+N | -N]
bind [-lpsvPSVX] [-m keymap] [-f file> printf [-v var] format [arguments]
break [n] pushd [-n] [+N | -N | dir]
builtin [shell-builtin [arg ...]] pwd [-LP]
caller [expr] read [-Eers] [-a array] [-d delim] [>
case WORD in [PATTERN [| PATTERN]...)> readarray [-d delim] [-n count] [-O >
cd [-L|[-P [-e]]] [-@] [dir] readonly [-aAf] [name[=value] ...] o>
command [-pVv] command [arg ...] return [n]
compgen [-V varname] [-abcdefgjksuv] > select NAME [in WORDS ... ;] do COMM>
complete [-abcdefgjksuv] [-pr] [-DEI]> set [-abefhkmnptuvxBCEHPT] [-o optio>
compopt [-o|+o option] [-DEI] [name .> shift [n]
continue [n] shopt [-pqsu] [-o] [optname ...]
coproc [NAME] command [redirections] source filename [arguments]
declare [-aAfFgiIlnrtux] [name[=value> suspend [-f]
dirs [-clpv] [+N] [-N] test [expr]
disown [-h] [-ar] [jobspec ... | pid > time [-p] pipeline
echo [-neE] [arg ...] times
enable [-a] [-dnps] [-f filename] [na> trap [-Plp] [[action] signal_spec ..>
eval [arg ...] true
exec [-cl] [-a name] [command [argume> type [-afptP] name [name ...]
exit [n] typeset [-aAfFgiIlnrtux] name[=value>
export [-fn] [name[=value] ...] or ex> ulimit [-SHabcdefiklmnpqrstuvxPRT] [>
false umask [-p] [-S] [mode]
fc [-e ename] [-lnr] [first] [last] o> unalias [-a] name [name ...]
fg [job_spec] unset [-f] [-v] [-n] [name ...]
for NAME [in WORDS ... ] ; do COMMAND> until COMMANDS; do COMMANDS-2; done
for (( exp1; exp2; exp3 )); do COMMAN> variables - Names and meanings of so>
function name { COMMANDS ; } or name > wait [-fn] [-p var] [id ...]
getopts optstring name [arg ...] while COMMANDS; do COMMANDS-2; done
hash [-lr] [-p pathname] [-dt] [name > { COMMANDS ; }
help [-dms] [pattern ...]
help: help [-dms] [pattern ...]
shift - Shift positional parameters.
shift: shift [n]
Shift positional parameters.
Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is
not given, it is assumed to be 1.
Exit Status:
Returns success unless N is negative or greater than $#.
builtin: builtin [shell-builtin [arg ...]]
shift: shift [n]
Shell commands matching keyword `read*'
read: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
readarray: readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
readonly: readonly [-aAf] [name[=value] ...] or readonly -p
read: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
readarray: readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
readonly: readonly [-aAf] [name[=value] ...] or readonly -p
:: :
Null command.
No effect; the command does nothing.
Exit Status:
Always succeeds.
NAME
: - Null command.
SYNOPSIS
:
DESCRIPTION
Null command.
No effect; the command does nothing.
Exit Status:
Always succeeds.
SEE ALSO
bash(1)
IMPLEMENTATION
Copyright (C) 2024 Free Software Foundation, Inc.
These shell commands are defined internally. Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
! PIPELINE history [-c] [-d offset] [n] or hist>
job_spec [&] if COMMANDS; then COMMANDS; [ elif C>
(( expression )) jobs [-lnprs] [jobspec ...] or jobs >
. filename [arguments] kill [-s sigspec | -n signum | -sigs>
: let arg [arg ...]
[ arg... ] local [option] name[=value] ...
[[ expression ]] logout [n]
alias [-p] [name[=value] ... ] mapfile [-d delim] [-n count] [-O or>
bg [job_spec ...] popd [-n] [+N | -N]
bind [-lpsvPSVX] [-m keymap] [-f file> printf [-v var] format [arguments]
break [n] pushd [-n] [+N | -N | dir]
builtin [shell-builtin [arg ...]] pwd [-LP]
caller [expr] read [-Eers] [-a array] [-d delim] [>
case WORD in [PATTERN [| PATTERN]...)> readarray [-d delim] [-n count] [-O >
cd [-L|[-P [-e]]] [-@] [dir] readonly [-aAf] [name[=value] ...] o>
command [-pVv] command [arg ...] return [n]
compgen [-V varname] [-abcdefgjksuv] > select NAME [in WORDS ... ;] do COMM>
complete [-abcdefgjksuv] [-pr] [-DEI]> set [-abefhkmnptuvxBCEHPT] [-o optio>
compopt [-o|+o option] [-DEI] [name .> shift [n]
continue [n] shopt [-pqsu] [-o] [optname ...]
coproc [NAME] command [redirections] source filename [arguments]
declare [-aAfFgiIlnrtux] [name[=value> suspend [-f]
dirs [-clpv] [+N] [-N] test [expr]
disown [-h] [-ar] [jobspec ... | pid > time [-p] pipeline
echo [-neE] [arg ...] times
enable [-a] [-dnps] [-f filename] [na> trap [-Plp] [[action] signal_spec ..>
eval [arg ...] true
exec [-cl] [-a name] [command [argume> type [-afptP] name [name ...]
exit [n] typeset [-aAfFgiIlnrtux] name[=value>
export [-fn] [name[=value] ...] or ex> ulimit [-SHabcdefiklmnpqrstuvxPRT] [>
false umask [-p] [-S] [mode]
fc [-e ename] [-lnr] [first] [last] o> unalias [-a] name [name ...]
fg [job_spec] unset [-f] [-v] [-n] [name ...]
for NAME [in WORDS ... ] ; do COMMAND> until COMMANDS; do COMMANDS-2; done
for (( exp1; exp2; exp3 )); do COMMAN> variables - Names and meanings of so>
function name { COMMANDS ; } or name > wait [-fn] [-p var] [id ...]
getopts optstring name [arg ...] while COMMANDS; do COMMANDS-2; done
hash [-lr] [-p pathname] [-dt] [name > { COMMANDS ; }
help [-dms] [pattern ...]
./builtins10.sub: line 39: help: no help topics match `bash'. Try `help help' or `man -k bash' or `info bash'.
unlimited
unlimited
./builtins11.sub: line 27: ulimit: +1999: invalid number
0
0
./builtins11.sub: line 37: ulimit: -g: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPRT] [limit]
./builtins11.sub: line 39: ulimit: max user processes: cannot modify limit: Operation not permitted
/tmp /bin
/tmp /bin
/bin /tmp
./builtins12.sub: line 21: pushd: -x: invalid number
pushd: usage: pushd [-n] [+N | -N | dir]
/tmp
./builtins12.sub: line 24: popd: -x: invalid number
popd: usage: popd [-n] [+N | -N]
/ /tmp
./builtins12.sub: line 27: popd: dir: invalid argument
popd: usage: popd [-n] [+N | -N]
/
/tmp
/tmp /
/bin /tmp /
./builtins12.sub: line 35: popd: -8: directory stack index out of range
./builtins12.sub: line 36: popd: +8: directory stack index out of range
/tmp /
/
./builtins.tests: line 322: exit: status: numeric argument required
after non-numeric arg to exit: 2
+49 -12
View File
@@ -15,10 +15,6 @@
set +p
set +o posix
ulimit -S -c 0 2>/dev/null
ulimit -c -S -- 1000 2>/dev/null
ulimit -c 2>/dev/null
# check that break breaks loops
for i in a b c; do echo $i; break; echo bad-$i; done
echo end-1
@@ -71,6 +67,10 @@ for i in a b c; do
done
echo end
# check arguments to break and continue that exceed the loop level
for f in 1 2 3; do break -- 5; done
for f in 1 2 3; do continue -- 5; done
# check that `eval' re-evaluates arguments, but `builtin' and `command' do not
AVAR='$BVAR'
BVAR=foo
@@ -87,7 +87,7 @@ BVAR=xxx eval echo $AVAR
unset -v AVAR BVAR
# test umask
# basic umask tests
mask=$(umask)
umask 022
umask
@@ -115,6 +115,7 @@ case "$(type -t test)" in
builtin) echo oops -- enable -n test failed ;;
*) echo enable -n test worked ;;
esac
enable -n | grep test
enable test
case "$(type -t test)" in
@@ -122,6 +123,9 @@ builtin) echo enable test worked ;;
*) echo oops -- enable test failed ;;
esac
enable -d notbuiltin
enable -d test
# test options to exec
(exec -a specialname ${THIS_SH} -c 'echo $0' )
(exec -l -a specialname ${THIS_SH} -c 'echo $0' )
@@ -145,11 +149,18 @@ command -p hash rm
# check out source/.
# sourcing a zero-length-file had better not be an error
rm -f /tmp/zero-length-file
cp /dev/null /tmp/zero-length-file
. /tmp/zero-length-file
rm -f $TMPDIR/zero-length-file-$$
cp /dev/null $TMPDIR/zero-length-file-$$
. $TMPDIR/zero-length-file-$$
echo $?
rm /tmp/zero-length-file
rm $TMPDIR/zero-length-file-$$
# and sourcing a file that doesn't end in a newline had better work too
SFILE=$TMPDIR/sourced-file-$$
printf 'echo no-newline' > $SFILE
. $SFILE
rm -f $SFILE
unset -v SFILE
AVAR=AVAR
@@ -262,6 +273,13 @@ kill -l 4096
# kill -l NAME should return the signal number
kill -l ${sigone/SIG/}
# kill -l NAME should work with and without the SIG prefix
x=$(kill -l INT)
y=$(kill -l SIGINT)
[[ $x == $y ]] || echo kill -l error with SIG prefix
unset -v x y
# test behavior of shopt xpg_echo
${THIS_SH} ./builtins2.sub
@@ -280,7 +298,26 @@ ${THIS_SH} ./builtins6.sub
# test behavior of command builtin after changing it to a pseudo-keyword
${THIS_SH} ./builtins7.sub
# this must be last -- it is a fatal error
exit status
# POSIX complete symbolic umask tests
${THIS_SH} ./builtins8.sub
echo after bad exit
# hash tests
${THIS_SH} ./builtins9.sub
# help tests
${THIS_SH} ./builtins10.sub
# ulimit tests
${THIS_SH} ./builtins11.sub
# pushd/popd/dirs
${THIS_SH} ./builtins12.sub
shift 0 # succeeds silently
options=$(set -o -B 2>&1 | wc -l)
[[ $options -gt 3 ]] || echo 'set: bad -o option name parsing'
# this no longer must be last -- it is no longer a fatal error
exit status
echo after non-numeric arg to exit: $?
+4
View File
@@ -12,3 +12,7 @@ echo $PWD
cd "$MYDIR"
rmdir $FULLDIR
cd /
cd /tmp
cd - # should print /
+4
View File
@@ -8,3 +8,7 @@ echo 'a\n\n\nb'
shopt -s xpg_echo
echo 'a\n\n\nb'
echo -p
set -o posix
echo 'a\tb\tc'
+3
View File
@@ -15,6 +15,9 @@ no
no
ok
esac
unset word ok 1
unset word ok 2
unset word ok 3
ok 1
ok 2
ok 3
+9
View File
@@ -66,6 +66,15 @@ case " " in ( [" "] ) echo ok;; ( * ) echo no;; esac
case esac in (esac) echo esac;; esac
case k in else|done|time|esac) for f in 1 2 3 ; do :; done esac
# null words and patterns
var=value
case $unset in
'') echo unset word ok 1 ;;&
$unset|$var) echo unset word ok 2 ;;&
unset|$unset) echo unset word ok 3 ;;
*) echo unset word bad ;;
esac
# tests of quote removal and pattern matching
${THIS_SH} ./case1.sub
${THIS_SH} ./case2.sub
+2
View File
@@ -43,5 +43,7 @@ Be Conservative in what you send and Liberal in what you accept
BE CONSERVATIVE IN WHAT YOU SEND AND LIBERAL IN WHAT YOU ACCEPT
Be conservative in what you send and liberal in what you accept
BE CONSERVATIVE IN WHAT YOU SEND AND LIBERAL IN WHAT YOU ACCEPT
acKnowledGEmEnt
oENoPHiLe
abcdexyz
ABCDEXYZ
+5 -2
View File
@@ -114,8 +114,11 @@ echo ${TEXT2^^}
M1=${S1^^[aeiou]}
M2=${U2,,[AEIOU]}
#echo ${M1} ${M1~}
#echo ${M2} ${M2~~}
# case-toggling modifiers are still in there for now
Z1=AcKnowledGEmEnt
Z2=OenOphIlE
echo ${Z1~}
echo ${Z2~~}
declare -l lower=aBcDe
lower+=XyZ
+323
View File
@@ -61,3 +61,326 @@ complete -d rmdir
complete -f more
complete -f -X '!*.+(gz|tgz)' gzcat
./complete.tests: line 123: complete: notthere: no completion specification
./complete.tests: line 130: complete: -V: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
./complete.tests: line 132: compgen: `invalid-name': not a valid identifier
.
unalias -- fee
unalias -- fi
unalias -- fum
!
%
(( ... ))
.
:
[
[[ ... ]]
alias
bg
bind
break
builtin
caller
case
cd
command
compgen
complete
compopt
continue
coproc
declare
dirs
disown
echo
enable
eval
exec
exit
export
false
fc
fg
for
for ((
function
getopts
hash
help
history
if
jobs
kill
let
local
logout
mapfile
popd
printf
pushd
pwd
read
readarray
readonly
return
select
set
shift
shopt
source
suspend
test
time
times
trap
true
type
typeset
ulimit
umask
unalias
unset
until
variables
wait
while
{ ... }
allexport
braceexpand
emacs
errexit
errtrace
functrace
hashall
histexpand
history
ignoreeof
interactive-comments
keyword
monitor
noclobber
noexec
noglob
nolog
notify
nounset
onecmd
physical
pipefail
posix
privileged
verbose
vi
xtrace
autocd
array_expand_once
assoc_expand_once
cdable_vars
cdspell
checkhash
checkjobs
checkwinsize
cmdhist
compat31
compat32
compat40
compat41
compat42
compat43
compat44
complete_fullquote
direxpand
dirspell
dotglob
execfail
expand_aliases
extdebug
extglob
extquote
failglob
force_fignore
globasciiranges
globskipdots
globstar
gnu_errfmt
histappend
histreedit
histverify
hostcomplete
huponexit
inherit_errexit
interactive_comments
lastpipe
lithist
localvar_inherit
localvar_unset
login_shell
mailwarn
no_empty_cmd_completion
nocaseglob
nocasematch
noexpand_translation
nullglob
patsub_replacement
progcomp
progcomp_alias
promptvars
restricted_shell
shift_verbose
sourcepath
varredir_close
xpg_echo
.
:
[
alias
bg
bind
break
builtin
caller
cd
command
compgen
complete
compopt
continue
declare
dirs
disown
echo
enable
eval
exec
exit
export
false
fc
fg
getopts
hash
help
history
jobs
kill
let
local
logout
mapfile
popd
printf
pushd
pwd
read
readarray
readonly
return
set
shift
shopt
source
suspend
test
times
trap
true
type
typeset
ulimit
umask
unalias
unset
wait
.
:
[
alias
bg
bind
break
builtin
caller
cd
command
compgen
complete
compopt
continue
declare
dirs
disown
echo
enable
eval
exec
exit
export
false
fc
fg
getopts
hash
help
history
jobs
kill
let
local
logout
mapfile
popd
printf
pushd
pwd
read
readarray
readonly
return
set
shift
shopt
source
suspend
test
times
trap
true
type
typeset
ulimit
umask
unalias
unset
wait
if
then
else
elif
fi
case
esac
for
select
while
until
do
done
in
function
time
{
}
!
[[
]]
coproc
./complete.tests: line 152: complete: -z: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
./complete.tests: line 154: compgen: -r: invalid option
compgen: usage: compgen [-V varname] [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
./complete.tests: line 155: compgen: noaction: invalid action name
./complete.tests: line 156: compgen: -D: invalid option
compgen: usage: compgen [-V varname] [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
./complete.tests: line 157: compgen: nooption: invalid option name
./complete.tests: line 159: compopt: nooption: invalid option name
+33
View File
@@ -124,3 +124,36 @@ complete -r notthere
complete -r
complete
# new complete/compgen -V option
# doesn't work for complete
complete -V name
compgen -V invalid-name -b
compgen -V array -b
echo ${array[0]}
# a more complicated example
unalias -a
alias fee=one fi=two fo=three fum=four
compgen -a -X 'fo*' -V vv -P 'unalias -- ' f
printf '%s\n' "${vv[@]}"
# some random compgen topics
compgen -A helptopic
builtin compgen -A setopt
compgen -A shopt
command compgen -b
compgen -A enabled
compgen -k
# and some errors
complete -z
complete -b
compgen -r
compgen -A noaction
compgen -D
compgen -o nooption
compopt -o nooption
+3 -1
View File
@@ -1,4 +1,6 @@
./comsub-eof0.sub: line 5: warning: here-document at line 3 delimited by end-of-file (wanted `EOF')
./comsub-eof0.sub: line 4: warning: here-document at line 2 delimited by end-of-file (wanted `EOF')
hi
./comsub-eof0.sub: line 11: warning: here-document at line 9 delimited by end-of-file (wanted `EOF')
hi
hi
./comsub-eof2.sub: line 2: warning: here-document at line 1 delimited by end-of-file (wanted `EOF')
+6
View File
@@ -1,3 +1,9 @@
# this works as it should, but with a warning
foo=$(cat <<EOF
hi
EOF)
echo $foo
unset -v foo
# it's only the space before the paren that makes this an error
# when I fix it, it will show up here
foo=$(cat <<EOF
+19 -1
View File
@@ -1,4 +1,4 @@
./comsub.tests: line 20: hijkl: command not found
./comsub.tests: line 19: hijkl: command not found
argv[1] = <ab>
argv[2] = <cd>
argv[1] = <abmn>
@@ -20,6 +20,11 @@ argv[1] = <foo\^Jbar>
argv[1] = <foobar>
argv[1] = <foo\^Jbar>
nested
blank ----
blank ----
blank ----
blank ----
func: v = comsub
#esac
a
ok 1
@@ -77,3 +82,16 @@ Mon Aug 29 20:03:02 EDT 2022
hey after x
./comsub6.sub: line 40: syntax error near unexpected token `)'
./comsub6.sub: line 40: `math1)'
123
123
0
123
123
0
Mon Aug 29 20:03:02 EDT 2022
Mon Aug 29 20:03:02 EDT 2022
Mon Aug 29 20:03:02 EDT 2022
Mon Aug 29 20:03:02 EDT 2022
123
before 123
in for 123
+25
View File
@@ -76,9 +76,34 @@ echo $(echo $( echo nested )
)
)
# empty comsubs, fork and nofork
echo blank --$(
)--
echo blank --$()--
echo blank --${
}--
echo blank --${ }--
BUILDDIR=/builds/test
read << EOC
Dir: ${BUILDDIR#<(echo a)/}
EOC
# return in a comsub inside a shell function should abort the comsub
func()
{
local v
v=$( echo comsub ; return ; echo after)
echo $FUNCNAME: v = $v
}
func
${THIS_SH} ./comsub1.sub
${THIS_SH} ./comsub2.sub
${THIS_SH} ./comsub3.sub
${THIS_SH} ./comsub4.sub
${THIS_SH} ./comsub5.sub
${THIS_SH} ./comsub6.sub
${THIS_SH} ./comsub7.sub
+10
View File
@@ -21,6 +21,16 @@
[[ "\\" =~ [\\] ]] || echo bad 5
[[ x =~ [z-a] ]] && echo bad 6
[[ x =~ [[:invalid:]abc] ]] && echo bad 7
exp='x\'
[[ x =~ $exp ]] && echo bad 8
exp='a(xb'
[[ x =~ $exp ]] && echo bad 9
[[ dog =~ [[=d=]].. ]] && echo ok 1
[[ d.. =~ [[=d=]]\.\. ]] && echo ok 2
[[ dog =~ ['[=d=]'].. ]] && echo ok 3 # dubious
+55 -1
View File
@@ -12,6 +12,8 @@ returns: 0
returns: 0
returns: 1
returns: 0
./cond.tests: line 65: [[: X: integer expected
returns: 2
returns: 0
returns: 1
returns: 1
@@ -27,7 +29,7 @@ returns: 0
returns: 1
returns: 1
returns: 0
./cond.tests: line 122: [[: 4+: syntax error: operand expected (error token is "+")
./cond.tests: line 126: [[: 4+: arithmetic syntax error: operand expected (error token is "+")
returns: 1
returns: 0
returns: 0
@@ -52,6 +54,12 @@ ok 2
ok 3
ok 4
ok 5
ok c1
ok c2
ok c3
ok c4
ok c5
ok c6
match 1
match 2
match 3
@@ -76,6 +84,11 @@ match control-a 2
match control-a 3
match control-a 4
match control-a 5
./cond-regexp2.sub: line 18: [[: invalid regular expression `[\.': brackets ([ ]) not balanced
./cond-regexp2.sub: line 24: [[: invalid regular expression `[z-a]': invalid character range
./cond-regexp2.sub: line 26: [[: invalid regular expression `[[:invalid:]abc]': invalid character class
./cond-regexp2.sub: line 29: [[: invalid regular expression `x\': trailing backslash (\)
./cond-regexp2.sub: line 32: [[: invalid regular expression `a(xb': parentheses not balanced
ok 1
ok 2
ok 3
@@ -140,3 +153,44 @@ ok 5
ok 6
ok 7
ok 8
bash: -c: line 1: unexpected token `EOF', expected `)'
bash: -c: line 2: syntax error: unexpected end of file
bash: -c: line 1: unexpected EOF while looking for `]]'
bash: -c: line 2: syntax error: unexpected end of file
bash: -c: line 1: syntax error in conditional expression
bash: -c: line 1: syntax error near `]'
bash: -c: line 1: `[[ ( -t X ) ]'
bash: -c: line 1: unexpected argument `&' to conditional unary operator
bash: -c: line 1: syntax error near `&'
bash: -c: line 1: `[[ -n &'
bash: -c: line 1: syntax error in conditional expression: unexpected token `&'
bash: -c: line 1: syntax error near `&'
bash: -c: line 1: `[[ -n XX &'
bash: -c: line 1: syntax error in conditional expression: unexpected token `&'
bash: -c: line 1: syntax error near `&'
bash: -c: line 1: `[[ -n XX & ]'
bash: -c: line 1: unexpected token `&', conditional binary operator expected
bash: -c: line 1: syntax error near `&'
bash: -c: line 1: `[[ 4 & ]]'
bash: -c: line 1: unexpected argument `&' to conditional binary operator
bash: -c: line 1: syntax error near `&'
bash: -c: line 1: `[[ 4 > & ]]'
bash: -c: line 1: unexpected token `&' in conditional command
bash: -c: line 1: syntax error near `&'
bash: -c: line 1: `[[ & ]]'
bash: -c: line 1: conditional binary operator expected
bash: -c: line 1: syntax error near `7'
bash: -c: line 1: `[[ -Q 7 ]]'
bash: -c: line 1: unexpected argument `<' to conditional unary operator
bash: -c: line 1: syntax error near `<'
bash: -c: line 1: `[[ -n < ]]'
ERR: 22: -[[ -n $unset ]]- failed
ERR: 28: -[[ -z nonempty ]]- failed
+ [[ -t X ]]
./cond-xtrace1.sub: line 6: [[: X: integer expected
+ [[ '' > 7 ]]
+ [[ -n X ]]
+ ivar=42
+ [[ 42 -eq 42 ]]
+ [[ -n a ]]
+ [[ -n b ]]
+18 -2
View File
@@ -61,6 +61,10 @@ echo returns: $?
[[ -z $UNSET ]]
echo returns: $?
# need to handle test syntax errors and longjmp
[[ -t X ]]
echo returns: $?
# the ==/= and != operators do pattern matching
[[ $TDIR == /usr/homes/* ]]
echo returns: $?
@@ -225,8 +229,20 @@ del=$'\177'
# allow reserved words after a conditional command just because
if [[ str ]] then [[ str ]] fi
# make sure pattern matching does the right thing with CTLESC
var=$'ab\001'
[[ $var == $var ]] && echo ok c1
[[ $var == a* ]] && echo ok c2
[[ $var == $'ab\001' ]] && echo ok c3
var=$'ab\001c'
[[ $var == $var ]] && echo ok c4
[[ $var == a* ]] && echo ok c5
[[ $var == $'ab\001'* ]] && echo ok c6
${THIS_SH} ./cond-regexp1.sub
${THIS_SH} ./cond-regexp2.sub
${THIS_SH} ./cond-regexp3.sub
${THIS_SH} ./cond-error1.sub
${THIS_SH} ./cond-xtrace1.sub
+70 -67
View File
@@ -1,7 +1,10 @@
debug lineno: 74 main
debug lineno: 77 main
FUNCNAME main
0 NULL
./dbg-support.tests: line 72: caller: -z: invalid option
caller: usage: caller [expr]
debug lineno: 78 main
debug lineno: 81 main
FUNCNAME main
debug lineno: 85 main
debug lineno: 30 fn1
debug lineno: 31 fn1
LINENO 31
@@ -12,9 +15,9 @@ BASH_SOURCE[0] ./dbg-support.tests
debug lineno: 34 fn1
FUNCNAME[0] fn1
debug lineno: 35 fn1
debug lineno: 35 fn1 81 ./dbg-support.tests
debug lineno: 35 fn1 85 ./dbg-support.tests
debug lineno: 36 fn1
debug lineno: 36 fn1 81 main ./dbg-support.tests
debug lineno: 36 fn1 85 main ./dbg-support.tests
debug lineno: 37 fn1
debug lineno: 37 fn1
debug lineno: 38 fn1
@@ -26,7 +29,7 @@ debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 30 fn1
debug lineno: 27 print_return_trap
debug lineno: 82 main
debug lineno: 86 main
debug lineno: 41 fn2
debug lineno: 42 fn2
fn2 here. Calling fn1...
@@ -45,7 +48,7 @@ debug lineno: 35 fn1 43 ./dbg-support.tests
debug lineno: 36 fn1
debug lineno: 36 fn1 43 fn2 ./dbg-support.tests
debug lineno: 37 fn1
debug lineno: 37 fn1 82 main ./dbg-support.tests
debug lineno: 37 fn1 86 main ./dbg-support.tests
debug lineno: 38 fn1
./dbg-support.tests: line 38: caller: foo: invalid number
caller: usage: caller [expr]
@@ -60,7 +63,7 @@ debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 41 fn2
debug lineno: 27 print_return_trap
debug lineno: 83 main
debug lineno: 87 main
debug lineno: 46 fn3
debug lineno: 47 fn3
LINENO 47
@@ -112,7 +115,7 @@ debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
debug lineno: 25 sourced_fn
debug lineno: 26 sourced_fn
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 83
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 87
debug lineno: 23 sourced_fn
debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
@@ -137,7 +140,7 @@ debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 46 fn3
debug lineno: 27 print_return_trap
debug lineno: 84 main
debug lineno: 88 main
debug lineno: 31 source
SOURCED LINENO 31
debug lineno: 32 source
@@ -160,7 +163,7 @@ debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
debug lineno: 25 sourced_fn
debug lineno: 26 sourced_fn
FUNCNAME[1]: source called from ./dbg-support.tests at line 84
FUNCNAME[1]: source called from ./dbg-support.tests at line 88
debug lineno: 23 sourced_fn
debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
@@ -175,24 +178,24 @@ debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 16 sourced_fn
debug lineno: 27 print_return_trap
debug lineno: 84 main
debug lineno: 88 main
debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 84 main
return lineno: 88 main
debug lineno: 27 print_return_trap
debug lineno: 87 main
debug lineno: 90 main
debug lineno: 91 main
debug lineno: 94 main
LINENO 31
LINENO 32
BASH_SOURCE[0] ./dbg-support.tests
FUNCNAME[0] fn1
90 ./dbg-support.tests
90 main ./dbg-support.tests
94 ./dbg-support.tests
94 main ./dbg-support.tests
./dbg-support.tests: line 38: caller: foo: invalid number
caller: usage: caller [expr]
debug lineno: 91 main
debug lineno: 95 main
fn2 here. Calling fn1...
LINENO 31
LINENO 32
@@ -200,11 +203,11 @@ BASH_SOURCE[0] ./dbg-support.tests
FUNCNAME[0] fn1
43 ./dbg-support.tests
43 fn2 ./dbg-support.tests
91 main ./dbg-support.tests
95 main ./dbg-support.tests
./dbg-support.tests: line 38: caller: foo: invalid number
caller: usage: caller [expr]
debug lineno: 92 main
debug lineno: 96 main
LINENO 47
BASH_SOURCE[0] ./dbg-support.tests
fn3 called from file `./dbg-support.tests' at line 0
@@ -214,13 +217,13 @@ SOURCED BASH_SOURCE[0] ./dbg-support.sub
SOURCED FN LINENO 18
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
FUNCNAME[1]: source called from ./dbg-support.tests at line 59
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 92
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 96
FUNCNAME[3]: main called from ./dbg-support.tests at line 0
debug lineno: 93 main
debug lineno: 97 main
fn4 here. Calling fn3...
LINENO 47
BASH_SOURCE[0] ./dbg-support.tests
fn3 called from file `./dbg-support.tests' at line 93
fn3 called from file `./dbg-support.tests' at line 97
fn4 called from file `./dbg-support.tests' at line 0
main called from file `./dbg-support.tests' at line 0
SOURCED LINENO 31
@@ -229,18 +232,18 @@ SOURCED FN LINENO 18
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
FUNCNAME[1]: source called from ./dbg-support.tests at line 59
FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 64
FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 93
FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 97
FUNCNAME[4]: main called from ./dbg-support.tests at line 0
debug lineno: 94 main
debug lineno: 98 main
SOURCED LINENO 31
SOURCED BASH_SOURCE[0] ./dbg-support.sub
SOURCED FN LINENO 18
FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
FUNCNAME[1]: source called from ./dbg-support.tests at line 94
FUNCNAME[1]: source called from ./dbg-support.tests at line 98
FUNCNAME[2]: main called from ./dbg-support.tests at line 0
return lineno: 94 main
debug lineno: 97 main
debug lineno: 100 main
return lineno: 98 main
debug lineno: 101 main
debug lineno: 104 main
debug lineno: 31 source
SOURCED LINENO 31
debug lineno: 32 source
@@ -263,7 +266,7 @@ debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
debug lineno: 25 sourced_fn
debug lineno: 26 sourced_fn
FUNCNAME[1]: source called from ./dbg-support.tests at line 100
FUNCNAME[1]: source called from ./dbg-support.tests at line 104
debug lineno: 23 sourced_fn
debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
@@ -278,39 +281,39 @@ debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 16 sourced_fn
debug lineno: 27 print_return_trap
debug lineno: 100 main
debug lineno: 104 main
debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 100 main
return lineno: 104 main
debug lineno: 27 print_return_trap
debug lineno: 101 main
debug lineno: 104 main
debug lineno: 104 main
debug lineno: 105 main
debug lineno: 108 main
debug lineno: 104 main
debug lineno: 104 main
debug lineno: 105 main
debug lineno: 108 main
debug lineno: 104 main
debug lineno: 104 main
debug lineno: 105 main
debug lineno: 106 main
debug lineno: 109 main
debug lineno: 112 main
debug lineno: 108 main
debug lineno: 108 main
debug lineno: 109 main
debug lineno: 112 main
debug lineno: 108 main
debug lineno: 108 main
debug lineno: 109 main
debug lineno: 110 main
Hit 2
debug lineno: 112 main
debug lineno: 108 main
debug lineno: 104 main
debug lineno: 104 main
debug lineno: 114 main
SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 114 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
debug lineno: 115 main
SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 115 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
debug lineno: 116 main
debug lineno: 117 main
SOURCED FN LINENO 18
FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 117
FUNCNAME[1]: main called from ./dbg-support.tests at line 0
debug lineno: 108 main
debug lineno: 118 main
SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 118 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
debug lineno: 119 main
SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 119 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
debug lineno: 120 main
debug lineno: 121 main
debug lineno: 122 main
SOURCED FN LINENO 18
FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 121
FUNCNAME[1]: main called from ./dbg-support.tests at line 0
debug lineno: 125 main
debug lineno: 126 main
debug lineno: 16 sourced_fn
debug lineno: 17 sourced_fn
debug lineno: 18 sourced_fn
@@ -322,7 +325,7 @@ debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
debug lineno: 25 sourced_fn
debug lineno: 26 sourced_fn
FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 122
FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 126
debug lineno: 23 sourced_fn
debug lineno: 23 sourced_fn
debug lineno: 24 sourced_fn
@@ -337,21 +340,21 @@ debug lineno: 25 print_return_trap
debug lineno: 26 print_return_trap
return lineno: 16 sourced_fn
debug lineno: 27 print_return_trap
debug lineno: 125 main
debug lineno: 130 main
debug lineno: 129 main
debug lineno: 134 main
debug lineno: 138 main
got it
debug lineno: 142 main
debug lineno: 143 main
debug lineno: 144 main
debug lineno: 143 main
debug lineno: 144 main
debug lineno: 142 main
debug lineno: 143 main
debug lineno: 144 main
debug lineno: 143 main
debug lineno: 144 main
debug lineno: 146 main
debug lineno: 147 main
debug lineno: 148 main
debug lineno: 147 main
debug lineno: 148 main
debug lineno: 146 main
debug lineno: 147 main
debug lineno: 148 main
debug lineno: 147 main
debug lineno: 148 main
debug lineno: 152 main
main: calling f1
f1: calling f2
f2: calling f3
+4
View File
@@ -67,6 +67,10 @@ fn4() {
#
# Test of support for debugging facilities in bash
#
caller
caller -z
# Test debugger set option functrace - set on. Not in vanilla Bash 2.05
#
set -o functrace
+3
View File
@@ -329,4 +329,7 @@ ${THIS_SH} ./dollar-star9.sub
# null strings as the positional parameters
${THIS_SH} ./dollar-star10.sub
# tests for expansions of $* when IFS=$'\1'
${THIS_SH} ./dollar-star11.sub
exit 0
+40
View File
@@ -742,3 +742,43 @@ argv[2] = <2>
var=1 2
argv[1] = <1 2>
argv[1] = <1 2>
argv[1] = <^Aaa^Abb^Acc^A--^Add^A>
argv[1] = <^A--^A>
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
ok 20
ok 21
ok 22
ok 23
ok 24
ok 25
ok 26
ok 27
ok 28
ok 29
ok 30
ok 31
ok 32
ok 33
ok 34
ok 35
ok 36
ok 37
ok 38
+8
View File
@@ -5,3 +5,11 @@ SECONDS ok
EPOCHSECONDS ok
EPOCHREALTIME ok
echo $BASH_COMMAND
110
111
112
113
114
./dynvar.tests: line 115: ((: LINENO / 0 : division by 0 (error token is "0 ")
0
0
+25 -1
View File
@@ -47,6 +47,11 @@ after=$SECONDS
if (( $after > $before )); then echo SECONDS ok; fi
unset before after
# do the best we can to test assignment to SECONDS
SECONDS=2
sleep 1
[[ $SECONDS -ge 10 ]] && echo 'SECONDS: bad value assignment'
# EPOCHSECONDS
# not exact, but should work
@@ -99,4 +104,23 @@ ${THIS_SH} -c 'echo $BASH_COMMAND'
# FUNCNAME tested in func.tests
# RANDOM tested in varenv.sh
# LINENO tested in dbg-support
# LINENO tested in dbg-support, misc additional tests here
arith_lineno()
{
echo $LINENO
for f in 1 ; do echo $LINENO; done
for (( f=1 ; f < 2; f++ )); do echo $LINENO; done
echo $(( $LINENO ))
(( 1 == 1 )) && echo $LINENO
(( LINENO / 0 ))
}
arith_lineno
# assignments to noassign variables are ignored
FUNCNAME=42
echo $? $FUNCNAME
GROUPS[0]=-1
echo $?
[[ ${GROUPS[0]} != -1 ]] || echo GROUPS noassign error
+221 -88
View File
@@ -1,110 +1,153 @@
./errors.tests: line 30: alias: -x: invalid option
alias: usage: alias [-p] [name[=value] ... ]
./errors.tests: line 31: unalias: -x: invalid option
unalias: usage: unalias [-a] name [name ...]
./errors.tests: line 32: alias: hoowah: not found
./errors.tests: line 33: unalias: hoowah: not found
./errors.tests: line 36: `1': not a valid identifier
./errors.tests: line 31: alias: -x: invalid option
alias: usage: alias [-p] [name[=value] ... ]
./errors.tests: line 32: unalias: -x: invalid option
unalias: usage: unalias [-a] name [name ...]
./errors.tests: line 33: alias: hoowah: not found
./errors.tests: line 34: unalias: hoowah: not found
./errors.tests: line 37: `1': not a valid identifier
./errors.tests: line 41: `f\1': not a valid identifier
./errors.tests: line 45: `invalid-name': not a valid identifier
./errors.tests: line 47: `f\1': not a valid identifier
./errors.tests: line 50: `1': not a valid identifier
./errors.tests: line 51: `f\1': not a valid identifier
./errors.tests: line 52: `invalid-name': not a valid identifier
./errors.tests: line 54: `1': not a valid identifier
./errors.tests: line 55: `f\1': not a valid identifier
./errors.tests: line 59: `$1': not a valid identifier
declare -fr func
./errors.tests: line 49: func: readonly function
./errors.tests: line 52: unset: -x: invalid option
./errors.tests: line 76: func: readonly function
./errors.tests: line 79: unset: -x: invalid option
unset: usage: unset [-f] [-v] [-n] [name ...]
./errors.tests: line 55: unset: func: cannot unset: readonly function
./errors.tests: line 58: declare: func: readonly function
./errors.tests: line 62: declare: -a: invalid option
./errors.tests: line 63: declare: -i: invalid option
./errors.tests: line 67: unset: XPATH: cannot unset: readonly variable
./errors.tests: line 73: unset: cannot simultaneously unset a function and a variable
./errors.tests: line 76: declare: -z: invalid option
./errors.tests: line 82: unset: func: cannot unset: readonly function
./errors.tests: line 85: declare: func: readonly function
./errors.tests: line 89: declare: -a: invalid option
./errors.tests: line 90: declare: -i: invalid option
./errors.tests: line 94: unset: XPATH: cannot unset: readonly variable
./errors.tests: line 100: unset: cannot simultaneously unset a function and a variable
./errors.tests: line 103: declare: -z: invalid option
declare: usage: declare [-aAfFgiIlnrtux] [name[=value] ...] or declare -p [-aAfFilnrtux] [name ...]
./errors.tests: line 78: declare: `-z': not a valid identifier
./errors.tests: line 79: declare: `/bin/sh': not a valid identifier
./errors.tests: line 83: declare: cannot use `-f' to make functions
./errors.tests: line 86: exec: -i: invalid option
./errors.tests: line 105: declare: `-z': not a valid identifier
./errors.tests: line 106: declare: `/bin/sh': not a valid identifier
./errors.tests: line 110: declare: cannot use `-f' to make functions
./errors.tests: line 113: exec: -i: invalid option
exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
./errors.tests: line 90: export: XPATH: not a function
./errors.tests: line 93: break: only meaningful in a `for', `while', or `until' loop
./errors.tests: line 94: continue: only meaningful in a `for', `while', or `until' loop
./errors.tests: line 97: shift: label: numeric argument required
./errors.tests: line 102: shift: too many arguments
./errors.tests: line 108: let: expression expected
./errors.tests: line 111: local: can only be used in a function
./errors.tests: line 114: logout: not login shell: use `exit'
./errors.tests: line 117: hash: notthere: not found
./errors.tests: line 120: hash: -v: invalid option
./errors.tests: line 120: export: XPATH: not a function
./errors.tests: line 123: break: only meaningful in a `for', `while', or `until' loop
./errors.tests: line 124: continue: only meaningful in a `for', `while', or `until' loop
./errors.tests: line 127: shift: label: numeric argument required
./errors.tests: line 132: shift: too many arguments
./errors.tests: line 138: let: expression expected
./errors.tests: line 141: local: can only be used in a function
./errors.tests: line 144: logout: not login shell: use `exit'
./errors.tests: line 147: hash: notthere: not found
./errors.tests: line 150: hash: -v: invalid option
hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
./errors.tests: line 124: hash: hashing disabled
./errors.tests: line 127: export: `AA[4]': not a valid identifier
./errors.tests: line 128: readonly: `AA[4]': not a valid identifier
./errors.tests: line 131: unset: [-2]: bad array subscript
./errors.tests: line 135: AA: readonly variable
./errors.tests: line 139: AA: readonly variable
./errors.tests: line 147: shift: 5: shift count out of range
./errors.tests: line 148: shift: -2: shift count out of range
./errors.tests: line 151: shopt: no_such_option: invalid shell option name
./errors.tests: line 152: shopt: no_such_option: invalid shell option name
./errors.tests: line 155: umask: 09: octal number out of range
./errors.tests: line 156: umask: `:': invalid symbolic mode character
./errors.tests: line 157: umask: `:': invalid symbolic mode operator
./errors.tests: line 160: umask: -i: invalid option
./errors.tests: line 153: hash: -d: option requires an argument
./errors.tests: line 157: hash: hashing disabled
./errors.tests: line 160: unset: [-2]: bad array subscript
./errors.tests: line 164: AA: readonly variable
./errors.tests: line 168: AA: readonly variable
./errors.tests: line 176: shift: 5: shift count out of range
./errors.tests: line 177: shift: -2: shift count out of range
./errors.tests: line 178: shift: 5: shift count out of range
./errors.tests: line 179: shift: -2: shift count out of range
./errors.tests: line 182: shopt: no_such_option: invalid shell option name
./errors.tests: line 183: shopt: no_such_option: invalid shell option name
./errors.tests: line 184: shopt: no_such_option: invalid option name
./errors.tests: line 187: umask: 09: octal number out of range
./errors.tests: line 188: umask: `:': invalid symbolic mode character
./errors.tests: line 189: umask: `:': invalid symbolic mode operator
./errors.tests: line 192: umask: -i: invalid option
umask: usage: umask [-p] [-S] [mode]
./errors.tests: line 164: umask: `u': invalid symbolic mode character
./errors.tests: line 173: VAR: readonly variable
./errors.tests: line 176: declare: VAR: readonly variable
./errors.tests: line 177: declare: VAR: readonly variable
./errors.tests: line 179: declare: unset: not found
./errors.tests: line 182: VAR: readonly variable
./errors.tests: line 196: umask: `p': invalid symbolic mode character
./errors.tests: line 205: VAR: readonly variable
./errors.tests: line 208: declare: VAR: readonly variable
./errors.tests: line 209: declare: VAR: readonly variable
./errors.tests: line 211: declare: unset: not found
./errors.tests: line 214: VAR: readonly variable
comsub: -c: line 1: syntax error near unexpected token `)'
comsub: -c: line 1: `: $( for z in 1 2 3; do )'
comsub: -c: line 1: syntax error near unexpected token `done'
comsub: -c: line 1: `: $( for z in 1 2 3; done )'
./errors.tests: line 189: cd: HOME not set
./errors.tests: line 190: cd: /tmp/xyz.bash: No such file or directory
./errors.tests: line 192: cd: OLDPWD not set
./errors.tests: line 193: cd: /bin/sh: Not a directory
./errors.tests: line 195: cd: /tmp/cd-notthere: No such file or directory
./errors.tests: line 198: .: filename argument required
./errors.tests: line 221: cd: HOME not set
./errors.tests: line 222: cd: /tmp/xyz.bash: No such file or directory
./errors.tests: line 224: cd: OLDPWD not set
./errors.tests: line 225: cd: /bin/sh: Not a directory
./errors.tests: line 227: cd: /tmp/cd-notthere: No such file or directory
./errors.tests: line 229: cd: too many arguments
bash: line 1: PWD: readonly variable
1
bash: line 1: OLDPWD: readonly variable
1
./errors.tests: line 236: .: filename argument required
.: usage: . filename [arguments]
./errors.tests: line 199: source: filename argument required
./errors.tests: line 237: source: filename argument required
source: usage: source filename [arguments]
./errors.tests: line 202: .: -i: invalid option
./errors.tests: line 240: .: -i: invalid option
.: usage: . filename [arguments]
./errors.tests: line 205: set: -q: invalid option
./errors.tests: line 243: set: -q: invalid option
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
./errors.tests: line 208: enable: sh: not a shell builtin
./errors.tests: line 208: enable: bash: not a shell builtin
./errors.tests: line 211: shopt: cannot set and unset shell options simultaneously
./errors.tests: line 214: read: var: invalid timeout specification
./errors.tests: line 217: read: `/bin/sh': not a valid identifier
./errors.tests: line 220: VAR: readonly variable
./errors.tests: line 223: readonly: -x: invalid option
./errors.tests: line 246: enable: sh: not a shell builtin
./errors.tests: line 246: enable: bash: not a shell builtin
./errors.tests: line 249: shopt: cannot set and unset shell options simultaneously
./errors.tests: line 252: read: -x: invalid option
read: usage: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
./errors.tests: line 255: read: var: invalid timeout specification
./errors.tests: line 258: read: `/bin/sh': not a valid identifier
./errors.tests: line 259: read: `/bin/sh': not a valid identifier
./errors.tests: line 260: read: `invalid-name': not a valid identifier
./errors.tests: line 263: VAR: readonly variable
./errors.tests: line 266: read: XX: invalid file descriptor specification
./errors.tests: line 267: read: 42: invalid file descriptor: Bad file descriptor
./errors.tests: line 270: mapfile: XX: invalid file descriptor specification
./errors.tests: line 271: mapfile: 42: invalid file descriptor: Bad file descriptor
./errors.tests: line 275: mapfile: empty array variable name
./errors.tests: line 276: mapfile: `invalid-var': not a valid identifier
./errors.tests: line 279: readonly: -x: invalid option
readonly: usage: readonly [-aAf] [name[=value] ...] or readonly -p
./errors.tests: line 226: eval: -i: invalid option
./errors.tests: line 282: eval: -i: invalid option
eval: usage: eval [arg ...]
./errors.tests: line 227: command: -i: invalid option
./errors.tests: line 283: command: -i: invalid option
command: usage: command [-pVv] command [arg ...]
./errors.tests: line 230: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
./errors.tests: line 231: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
./errors.tests: line 234: trap: NOSIG: invalid signal specification
./errors.tests: line 237: trap: -s: invalid option
trap: usage: trap [-lp] [[arg] signal_spec ...]
./errors.tests: line 243: return: can only `return' from a function or sourced script
./errors.tests: line 247: break: 0: loop count out of range
./errors.tests: line 251: continue: 0: loop count out of range
./errors.tests: line 256: builtin: bash: not a shell builtin
./errors.tests: line 260: bg: no job control
./errors.tests: line 261: fg: no job control
./errors.tests: line 264: kill: -s: option requires an argument
./errors.tests: line 266: kill: S: invalid signal specification
./errors.tests: line 268: kill: `': not a pid or valid job spec
./errors.tests: line 286: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
./errors.tests: line 287: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
./errors.tests: line 290: trap: NOSIG: invalid signal specification
./errors.tests: line 293: trap: -s: invalid option
trap: usage: trap [-Plp] [[action] signal_spec ...]
./errors.tests: line 299: return: can only `return' from a function or sourced script
./errors.tests: line 303: break: 0: loop count out of range
./errors.tests: line 307: continue: 0: loop count out of range
./errors.tests: line 312: builtin: -x: invalid option
builtin: usage: builtin [shell-builtin [arg ...]]
./errors.tests: line 315: builtin: bash: not a shell builtin
./errors.tests: line 319: bg: no job control
./errors.tests: line 320: fg: no job control
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
./errors.tests: line 273: set: trackall: invalid option name
./errors.tests: line 277: xx: readonly variable
./errors.tests: line 324: kill: -s: option requires an argument
./errors.tests: line 326: kill: S: invalid signal specification
./errors.tests: line 328: kill: `': not a pid or valid job spec
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
./errors.tests: line 332: kill: SIGBAD: invalid signal specification
./errors.tests: line 334: kill: BAD: invalid signal specification
./errors.tests: line 336: kill: @12: arguments must be process or job IDs
./errors.tests: line 339: unset: BASH_LINENO: cannot unset
./errors.tests: line 339: unset: BASH_SOURCE: cannot unset
./errors.tests: line 342: set: trackall: invalid option name
./errors.tests: line 343: set: -q: invalid option
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
./errors.tests: line 344: set: -i: invalid option
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
./errors.tests: line 348: xx: readonly variable
1
./errors1.sub: line 14: .: -i: invalid option
.: usage: . filename [arguments]
./errors1.sub: line 22: shift: -4: shift count out of range
./errors1.sub: line 23: shift: -4: shift count out of range
./errors1.sub: line 27: break: -1: loop count out of range
./errors1.sub: line 28: continue: -1: loop count out of range
./errors1.sub: line 29: break: -5: loop count out of range
./errors1.sub: line 30: continue: -5: loop count out of range
after f
./errors2.sub: line 3: ${$NO_SUCH_VAR}: bad substitution
1
@@ -115,7 +158,18 @@ TEST
2
./errors4.sub: line 20: var: readonly variable
after readonly assignment
./errors4.sub: line 26: break: x: numeric argument required
./errors4.sub: line 27: var: readonly variable
./errors4.sub: line 31: f: readonly variable
./errors4.sub: line 34: var: readonly variable
1) 1
2) 2
3) 3
#? ./errors4.sub: line 37: var: readonly variable
1) 1
2) 2
3) 3
#? ./errors4.sub: line 40: var: readonly variable
./errors4.sub: line 45: break: x: numeric argument required
1
2
./errors4.sub: line 20: var: readonly variable
@@ -177,6 +231,7 @@ after non-special builtin: 0
after special builtin: 0
./errors7.sub: line 27: x: readonly variable
./errors7.sub: line 29: x: readonly variable
./errors7.sub: line 32: v: readonly variable
./errors7.sub: line 21: x: readonly variable
after no such command: 1
./errors7.sub: line 23: x: readonly variable
@@ -184,6 +239,7 @@ after non-special builtin: 1
./errors7.sub: line 25: x: readonly variable
./errors7.sub: line 27: x: readonly variable
./errors7.sub: line 29: x: readonly variable
./errors7.sub: line 32: v: readonly variable
./errors8.sub: eval: line 7: syntax error: unexpected end of file
ok 1
./errors8.sub: line 8: v: readonly variable
@@ -196,13 +252,90 @@ ok 4
ok 5
./errors8.sub: line 14: set: notanoption: invalid option name
ok 6
./errors8.sub: line 16: /notthere: No such file or directory
ok 7
./errors8.sub: line 17: .: -x: invalid option
.: usage: . filename [arguments]
ok 8
DEBUG
./errors9.sub: line 6: [[: ++: syntax error: operand expected (error token is "+")
./errors9.sub: line 6: [[: ++: arithmetic syntax error: operand expected (error token is "+")
DEBUG
./errors9.sub: line 8: ((: -- : syntax error: operand expected (error token is "- ")
./errors9.sub: line 8: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
DEBUG
./errors9.sub: line 10: ((: -- : syntax error: operand expected (error token is "- ")
./errors9.sub: line 10: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
invalid numeric argument
bash: line 1: exit: abcde: numeric argument required
after exit: 2
bash: line 1: break: abcde: numeric argument required
bash: line 1: continue: abcde: numeric argument required
bash: line 1: shift: abcde: numeric argument required
after shift: 2
bash: line 1: return: abcde: numeric argument required
after return: 2
bash: line 1: exit: abcde: numeric argument required
bash: line 1: break: abcde: numeric argument required
bash: line 1: continue: abcde: numeric argument required
bash: line 1: shift: abcde: numeric argument required
bash: line 1: return: abcde: numeric argument required
./errors10.sub: line 38: history: abcde: numeric argument required
after history: 2
./errors10.sub: line 40: history: too many arguments
after history: 2
too many arguments
errors: line 3: exit: too many arguments
after exit: 2
errors: line 3: return: too many arguments
after return: 2
errors: line 3: shift: too many arguments
after shift: 2
errors: line 3: break: too many arguments
after break: 2
errors: line 3: continue: too many arguments
after continue: 2
errors: line 3: exit: too many arguments
after exit: 2
errors: line 3: return: too many arguments
after return: 2
errors: line 3: shift: too many arguments
after shift: 2
errors: line 3: break: too many arguments
after break: 2
errors: line 3: continue: too many arguments
after continue: 2
bash: line 1: readonly: `non-identifier': not a valid identifier
after: 1
bash: line 1: export: `non-identifier': not a valid identifier
after: 1
bash: line 1: readonly: `non-identifier': not a valid identifier
bash: line 1: readonly: `invalid+ident': not a valid identifier
after: 1
bash: line 1: export: `non-identifier': not a valid identifier
bash: line 1: export: `invalid+ident': not a valid identifier
after: 1
sh: line 1: readonly: `non-identifier': not a valid identifier
sh: line 1: export: `non-identifier': not a valid identifier
sh: line 1: readonly: `non-identifier': not a valid identifier
sh: line 1: export: `non-identifier': not a valid identifier
bash: line 1: readonly: `non-identifier': not a valid identifier
command: 1
bash: line 1: export: `non-identifier': not a valid identifier
command: 1
sh: line 1: readonly: `non-identifier': not a valid identifier
command: 1
sh: line 1: export: `non-identifier': not a valid identifier
command: 1
bash: line 1: export: `AA[4]': not a valid identifier
array: 1
bash: line 1: readonly: `AA[4]': not a valid identifier
array: 1
sh: line 1: export: `AA[4]': not a valid identifier
sh: line 1: readonly: `AA[4]': not a valid identifier
bash: line 1: return: can only `return' from a function or sourced script
after return
bash: line 1: return: can only `return' from a function or sourced script
./errors.tests: line 305: `!!': not a valid identifier
sh: line 1: unset: a: cannot unset: readonly variable
sh: line 1: unset: `a-b': not a valid identifier
sh: line 1: /nosuchfile: No such file or directory
sh: line 1: trap: SIGNOSIG: invalid signal specification
after trap
./errors.tests: line 393: `!!': not a valid identifier
+94 -6
View File
@@ -24,6 +24,7 @@ set +e
set +o posix
# various alias/unalias errors
unalias
# at some point, this may mean to `export' an alias, like ksh, but
# for now it is an error
@@ -33,7 +34,33 @@ alias hoowah
unalias hoowah
# the iteration variable must be a valid identifier
for 1 in a b c; do echo $1; done
for 1 in a b c
do
echo $1
done
for f\1 in a b c ; do echo $f ; done
# in posix mode, it's a fatal error
(set -o posix
for invalid-name in a b c; do echo $1; done; echo after posix for)
(set -o posix
for f\1 in a b c ; do echo $f ; done; echo after posix for 2)
# same with select
select 1 in a b c; do echo $REPLY; done
select f\1 in a b c ; do echo $REPLY ; done
select invalid-name in a b c; do echo $REPLY; done
(set -o posix ; select 1 in a b c; do echo $REPLY; done; echo after posix select)
(set -o posix ; select f\1 in a b c ; do echo $REPLY ; done ; echo after posix select 2)
# even in functions
bad-select()
{
select $1 in a b c ; do echo $REPLY ; done
}
bad-select 'a b'
unset -f bad-select
# try to rebind a read-only function
func()
@@ -85,6 +112,9 @@ declare -f func='() { echo "this is func"; }'
# bad option to exec -- this should not exit the script
exec -i /bin/sh
# trying to exec non-executable file is a fatal error
( exec ./errors1.sub 2>/dev/null ; echo after failed exec )
# try to export -f something that is not a function -- this should be
# an error, not create an `invisible function'
export -f XPATH
@@ -119,14 +149,13 @@ hash notthere
# bad option to hash, although it may mean `verbose' at some future point
hash -v
# hash -d requires an argument
hash -d
# turn off hashing, then try to hash something
set +o hashall
hash -p ${THIS_SH} ${THIS_SH##*/}
# bad identifiers to declare/readonly/export
export AA[4]
readonly AA[4]
declare -a AA
unset AA[-2]
@@ -146,10 +175,13 @@ AA=(one two three)
shopt -s shift_verbose
shift $(( $# + 5 ))
shift -2
shift -- $(( $# + 5 ))
shift -- -2
# bad shell options
shopt -s no_such_option
shopt no_such_option
shopt -s -o no_such_option
# non-octal digits for umask and other errors
umask 09
@@ -161,7 +193,7 @@ umask -i
# bad assignments shouldn't change the umask
mask=$(umask)
umask g=u
umask g=p
mask2=$(umask)
if [ "$mask" != "$mask2" ]; then
echo "umask errors change process umask"
@@ -193,6 +225,12 @@ cd -
cd /bin/sh # error - not a directory
OLDPWD=/tmp/cd-notthere
cd -
# too many arguments
cd one two three
# cd doesn't like it if PWD is readonly
${THIS_SH} -c 'readonly PWD ; cd / ; echo $?' bash
# or if OLDPWD is readonly
${THIS_SH} -c 'readonly OLDPWD ; cd / ; echo $?' bash
# various `source/.' errors
.
@@ -210,15 +248,33 @@ enable sh bash
# try to set and unset shell options simultaneously
shopt -s -u checkhash
# error
read -x
# this is an error -- bad timeout spec
read -t var < /dev/null
# try to read into an invalid identifier
read /bin/sh < /dev/null
read A /bin/sh < /dev/null
read -a invalid-name < /dev/null
# try to read into a readonly variable
read VAR < /dev/null
# invalid file descriptor
read -u XX < /dev/null
read -u 42 < /dev/null
# same with mapfile
mapfile -u XX A < /dev/null
mapfile -u 42 A < /dev/null
unset -v A
# invalid identifier arguments to mapfile
mapfile '' </dev/null
mapfile invalid-var < /dev/null
# bad option to readonly/export
readonly -x foo
@@ -252,6 +308,9 @@ for z in 1 2 3; do
echo $x
done
# invalid option
builtin -x
# builtin with non-builtin
builtin bash
@@ -261,6 +320,7 @@ bg
fg
# argument required
kill
kill -s
# bad argument
kill -S
@@ -268,9 +328,20 @@ kill -S
kill -INT ''
# argument required
kill -INT
# bad signal specification
kill -l SIGBAD
# bad signal specification
kill -l BAD
# bad process specification
kill -HUP @12
# cannot unset non-unsettable variables
unset -v BASH_LINENO BASH_SOURCE
# bad shell option names
set -o trackall # bash is not ksh
set -q # this is an error
set -i # this is not allowed
# problem with versions through bash-4.2
readonly xx=5
@@ -294,9 +365,26 @@ ${THIS_SH} -o posix ./errors7.sub
${THIS_SH} ./errors8.sub
${THIS_SH} ./errors9.sub
# invalid numeric arguments and too many arguments
${THIS_SH} ./errors10.sub
# invalid identifiers to readonly/export
${THIS_SH} ./errors11.sub
${THIS_SH} -c 'return ; echo after return' bash
${THIS_SH} -o posix -c 'return ; echo after return' bash
# various posix-mode special builtin fatal (or not) errors
# posix says unsetting readonly variables is a fatal error
${THIS_SH} -o posix -c 'readonly a=a ; unset -v a; echo after unset 1' sh
# the same with non-identifiers
${THIS_SH} -o posix -c 'unset -v a-b; echo after unset 2' sh
# and sourcing a non-existent file is fatal too
${THIS_SH} -o posix -c '. /nosuchfile ; echo after source' sh
# but trap specifying a bad signal nunber is non-fatal
${THIS_SH} -o posix -c 'trap "echo bad" SIGNOSIG; echo after trap' sh
# this must be last!
# in posix mode, a function name must be a valid identifier
# this can't go in posix2.tests, since it causes the shell to exit
+5 -4
View File
@@ -20,13 +20,14 @@ f()
set -- a b c
shift -4
shift -- -4
f
for f in 1 2 3; do
break -1
done
for f in 1 2 3; do break -1; done
for f in 1 2 3; do continue -1; done
for f in 1 2 3; do break -- -5; done
for f in 1 2 3; do continue -- -5; done
f()
{
+16
View File
@@ -23,6 +23,22 @@ for num in 1 2 3 4 5; do
done
echo after readonly assignment
# can't have the variable in a for command be readonly
for var in 1 2 3 4 5; do echo $var; done
# but in posix mode these are fatal errors
(set -o posix
for f in 1 2 3 4; do readonly f; done ; echo after for readonly assignment)
(set -o posix
for var in 1 2 3 4; do echo $var; done; echo after posix for readonly variable)
# same with select
select var in 1 2 3; do echo $REPLY; done <<<1
(set -o posix
select var in 1 2 3; do echo $REPLY; done <<<1 ; echo after posix select readonly variable)
# non-numeric arguments to break are fatal errors for all non-interactive shells
for f in 1 2 3 4 5
do
+3
View File
@@ -28,3 +28,6 @@ echo after special builtin: $? )
echo after assignment error: $? )
( x=8
echo after assignment statement error: $? )
( readonly v; : ${v:=val}
echo variable assignment error )
+3
View File
@@ -12,3 +12,6 @@ command shift 12 || echo ok 4
command return 16 || echo ok 5
command set -o notanoption || echo ok 6
command . /notthere || echo ok 7
command . -x true || echo ok 8
+54 -6
View File
@@ -5,17 +5,22 @@ after exec1.sub with args: 0
after exec1.sub without args: 0
after exec1.sub: one two three
./execscript: line 21: notthere: command not found
./execscript: line 37: notthere: command not found
127
we would do something here with notthere
/tmp/bash: notthere: No such file or directory
127
/bin/sh: /bin/sh: cannot execute binary file
126
./execscript: line 40: /: Is a directory
./execscript: line 64: /: Is a directory
126
/: /: Is a directory
126
./execscript: line 47: .: /: is a directory
bash: line 1: exec: .: cannot execute: Is a directory
posix-bash: line 1: exec: .: cannot execute: Is a directory
bash: line 1: exec: .: cannot execute: Is a directory
posix-bash: line 1: exec: .: cannot execute: Is a directory
./execscript: line 79: .: /: is a directory
1
126
0
@@ -31,11 +36,17 @@ trap -- '' SIGTERM
trap -- 'echo USR1' SIGUSR1
USR1
EXIT
./execscript: line 71: notthere: No such file or directory
./execscript: line 103: notthere: command not found
127
./execscript: line 74: notthere: No such file or directory
./execscript: line 105: notthere: command not found
127
./execscript: line 77: notthere: command not found
./execscript: line 107: notthere: command not found
127
./execscript: line 113: notthere: command not found
127
./execscript: line 115: notthere: command not found
127
./execscript: line 117: notthere: command not found
127
this is sh
this is sh
@@ -59,6 +70,13 @@ this is ohio-state
1
0
1
1 hi 1
2 hi 0
!
!
0
1
0
testb
expand_aliases on
1
@@ -170,3 +188,33 @@ w
x
y
z
Darwin
x
archive
install
s
sub1
sub2
test
68
archive
install
s
sub1
sub2
test
44
archive
install
s
sub1
sub2
test
86
2
78
1 start
2 start
sub3
1 done
42
+16
View File
@@ -65,3 +65,19 @@ echo $?
echo $?
rm -f /tmp/notwrite
!; echo 1 hi $?
!& echo 2 hi $?
(echo !)
#echo !(echo c)
echo !>/dev/null
echo !</dev/null
! &
echo $?
!
echo $?
{ time & } 2>/dev/null
echo $?
+45 -2
View File
@@ -1,3 +1,16 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
export LC_ALL=C
export LANG=C
@@ -5,6 +18,9 @@ if [ $UID -eq 0 ]; then
echo "execscript: the test suite should not be run as root" >&2
fi
# this should succeed silently
$cmd &
set -- one two three
echo before exec1.sub: "$@"
echo calling exec1.sub
@@ -21,6 +37,14 @@ export PATH
notthere
echo $?
# now let's set up a command-not-found hook
command_not_found_handle()
{
echo we would do something here with $1
}
notthere a b c
unset -f command_not_found_handle
# this is iffy, since the error messages may vary from system to system
# and /tmp might not exist
ln -s ${THIS_SH} /tmp/bash 2>/dev/null
@@ -43,6 +67,14 @@ echo $?
${THIS_SH} /
echo $?
# trying to exec a directory is a fatal error
${THIS_SH} -c 'exec . ; default: after exec directory' bash
POSIXLY_CORRECT=1 ${THIS_SH} -c 'exec . ; posix: after exec directory' posix-bash
# even if preceded by `command'
${THIS_SH} -c 'command exec . ; default: after command exec directory 2' bash
POSIXLY_CORRECT=1 ${THIS_SH} -c 'command exec . ; posix: after command exec directory 2' posix-bash
# try sourcing a directory
. /
echo $?
@@ -65,15 +97,23 @@ ${THIS_SH} ./exec3.sub
rm -f $TMPDIR/bashenv
unset BASH_ENV
# these results should be the same as with an empty PATH
PATH=.
notthere
echo $?
command notthere
echo $?
command -p notthere
echo $?
# we're resetting the $PATH to empty, so this should be last
PATH=
notthere
echo $?
command notthere
echo $?
command -p notthere
echo $?
@@ -158,3 +198,6 @@ $THIS_SH -c '/bin/echo c && /bin/echo d && echo e'
${THIS_SH} ./exec13.sub
${THIS_SH} ./exec14.sub
# problems with fork optimization in bash-5.2
${THIS_SH} ./exec15.sub
+17 -1
View File
@@ -88,6 +88,8 @@ argv[1] = <abc>
argv[1] = <abc>
argv[1] = <posix>
argv[1] = <10>
argv[1] = <5>
argv[1] = <5>
argv[1] = <file.o>
argv[1] = <posix>
argv[1] = </src/cmd>
@@ -164,6 +166,20 @@ argv[2] = <^?>
argv[1] = <^A^?>
argv[1] = <^A^?^A^?>
argv[1] = <^A^A^?>
argv[1] = <\^A>
argv[1] = <^A>
argv[1] = <\^A>
argv[1] = <\^A>
argv[1] = <^A>
argv[1] = <^A>
argv[1] = <^A^A>
argv[1] = <^A^A>
argv[1] = <\^A>
argv[1] = <\^A>
argv[1] = <\^A^?>
argv[1] = <\^A^?>
argv[1] = <^\^A ^\^?>
argv[1] = <^A ^_>
0.net
0.net0
@@ -236,7 +252,7 @@ declare -- var="x\001y\177z"$
argv[1] = <$'x\001y\177z'>
argv[1] = <x^Ay^?z>
var=$'x\001y\177z'
./exp8.sub: line 30: xyz: syntax error: invalid arithmetic operator (error token is "z")
./exp8.sub: line 30: xyz: arithmetic syntax error: invalid arithmetic operator (error token is "z")
declare -a array=()
declare -a array=([0]=$'x\001y\177z')
argv[1] = <x^Ay^?z>
+9
View File
@@ -237,6 +237,15 @@ POSIX=/usr/posix
expect '<10>'
recho ${#POSIX}
# this was a problem through bash-5.2 -- it would skip random numbers because
# of multiple calls to find_variable
RANDOM=42
expect '<5>'
recho ${#RANDOM} # 17772
declare -i RANDOM=42
expect '<5>'
recho ${#RANDOM} # 17772
# remove shortest trailing match
x=file.c
expect '<file.o>'
+20
View File
@@ -32,3 +32,23 @@ recho $FOO
recho ''
recho ''
recho ''
# tests of backslash-escaped CTLESC
recho "${_+\}"
recho ${_+\}
recho "${_+\\}"
recho ${_+\\}
recho "${_+}"
recho ${_+}
recho "${_+}"
recho ${_+}
recho $'\\\1'
recho "\\"
recho "\\"
recho \\
recho $'\c\\\001 \c\\\177'
recho $'\c \c'
+1 -1
View File
@@ -5,7 +5,7 @@ exportfunc ok 2
./exportfunc.tests: line 43: cve7169-bad2: No such file or directory
./exportfunc1.sub: line 14: maximum here-document count exceeded
./exportfunc.tests: line 72: HELLO_WORLD: No such file or directory
eval ok
./exportfunc.tests: eval: line 83: unexpected EOF while looking for matching `}'
./exportfunc3.sub: line 23: export: foo=bar: cannot export
status: 1
equals-1
+1
View File
@@ -78,6 +78,7 @@ env -i BASH_FUNC_x%%='() { _; } >_[${ $() }] { id; }' ${THIS_SH} -c : 2>/dev/nul
env BASH_FUNC_x%%=$'() { _;}>_[$($())]\n{ echo vuln;}' ${THIS_SH} -c : 2>/dev/null
eval 'x() { _;}>_[$($())] { echo vuln;}' 2>/dev/null
# this fails looking for closing `}' now that `${ ' has syntactic meaning
eval 'foo() { _; } >_[${ $() }] ;{ echo eval ok; }'
# other tests fixed in bash43-030 concerning function name transformation
+7
View File
@@ -182,3 +182,10 @@ no dotglob: .a .foo bar
? . .. .a .foo
*
bar
extglob off
x
extglob off
extglob off
extglob off
extglob off
extglob off
+6
View File
@@ -379,6 +379,11 @@ shopt -u globstar
# in the right place
builtin cd "$MYDIR"
# seg fault in bash-5.2
foo=
foo=${foo/#*([.])}
unset foo
${THIS_SH} ./extglob1.sub
${THIS_SH} ./extglob1a.sub
${THIS_SH} ./extglob3.sub
@@ -386,5 +391,6 @@ ${THIS_SH} ./extglob4.sub
${THIS_SH} ./extglob5.sub
${THIS_SH} ./extglob6.sub
${THIS_SH} ./extglob7.sub
${THIS_SH} ./extglob8.sub
exit 0
+94
View File
@@ -166,4 +166,98 @@ after FUNCNEST unset: f = 201
./func4.sub: line 23: foo: maximum function nesting level exceeded (20)
1
after FUNCNEST assign: f = 38
./func5.sub: line 31: `sys$read': not a valid identifier
11111 ()
{
printf "FUNCNAME: %s\n" $FUNCNAME
}
function a=2 ()
{
printf "FUNCNAME: %s\n" $FUNCNAME
}
function 11111 ()
{
printf "FUNCNAME: %s\n" $FUNCNAME
}
function a=2 ()
{
printf "FUNCNAME: %s\n" $FUNCNAME
}
FUNCNAME: a=2
<(:)
<(:) is a function
<(:) ()
{
echo $FUNCNAME
}
posix mode:
type
break is a special shell builtin
builtin
command -v
break
command -V
break is a special shell builtin
type -a
break is a special shell builtin
break is a function
break ()
{
echo inside function $FUNCNAME
}
declare
break ()
{
echo inside function $FUNCNAME
}
execution
default mode:
type
break is a function
break ()
{
echo inside function $FUNCNAME
}
function
command -v
break
command -V
break is a function
break ()
{
echo inside function $FUNCNAME
}
type -a
break is a function
break ()
{
echo inside function $FUNCNAME
}
break is a shell builtin
declare
break ()
{
echo inside function $FUNCNAME
}
execution
inside function break
./func5.sub: line 86: `break': is a special builtin
./func5.sub: line 92: `!!': not a valid identifier
!! is a function
!! ()
{
fc -s "$@"
}
!! is a function
function !! ()
{
fc -s "$@"
}
5
rfunc ()
{
local -;
local var;
local -p
}
declare -fr rfunc
+15
View File
@@ -166,6 +166,7 @@ export -f zf
${THIS_SH} -c 'type -t zf'
${THIS_SH} -c 'type zf'
unset -f zf
${THIS_SH} ./func1.sub
@@ -179,6 +180,9 @@ ${THIS_SH} ./func3.sub
# FUNCNEST testing
${THIS_SH} ./func4.sub
# function naming restrictions
${THIS_SH} ./func5.sub
unset -f myfunction
myfunction() {
echo "bad shell function redirection"
@@ -195,4 +199,15 @@ segv()
segv
echo $?
# functions can have attributes
rfunc()
{
local -
local var
local -p
}
readonly -f rfunc
readonly -f
exit 0
+2
View File
@@ -66,3 +66,5 @@ OPTARG = x = ?
unset x = ?
declare -r RO="foo"
declare -r RO="foo"
./getopts10.sub: line 33: V: readonly variable
1
+6
View File
@@ -28,3 +28,9 @@ typeset -p RO
getopts x x
typeset -p RO
readonly V
getopts x V
echo $?
+17 -1
View File
@@ -125,6 +125,22 @@ a aa b bb
.a .aa .b .bb a aa b bb
.a .aa .b .bb
. .. .a .aa .b .bb
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
mksyntax.dSYM mksyntax mksignames.o mksignames make_cmd.o mailcheck.o
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
mksyntax mksignames make_cmd.o mailcheck.o mksignames.o mksyntax.dSYM
mksyntax.dSYM mksignames.o mailcheck.o make_cmd.o mksignames mksyntax
mksyntax mksignames make_cmd.o mailcheck.o mksignames.o mksyntax.dSYM
mksyntax.dSYM mksignames.o mailcheck.o make_cmd.o mksignames mksyntax
mksyntax mksignames make_cmd.o mailcheck.o mksignames.o mksyntax.dSYM
mksyntax.dSYM mksignames.o mailcheck.o make_cmd.o mksignames mksyntax
argv[1] = <a>
argv[2] = <abc>
argv[3] = <abd>
@@ -139,7 +155,7 @@ argv[2] = <abc>
argv[3] = <abd>
argv[4] = <abe>
tmp/l1 tmp/l2 tmp/*4 tmp/l3
./glob.tests: line 66: no match: tmp/*4
./glob.tests: line 67: no match: tmp/*4
argv[1] = <bdir/>
argv[1] = <*>
argv[1] = <a*>
+1
View File
@@ -31,6 +31,7 @@ ${THIS_SH} ./glob7.sub
${THIS_SH} ./glob8.sub
${THIS_SH} ./glob9.sub
${THIS_SH} ./glob10.sub
${THIS_SH} ./glob11.sub
MYDIR=$PWD # save where we are
+1 -1
View File
@@ -15,7 +15,7 @@
# test basic behavior of globskipdots
TDIR=/tmp/dotglob-$$
{ mkdir $TDIR && cd $TDIR; } || exit 1
{ mkdir $TDIR && cd -L $TDIR; } || exit 1
touch a b aa bb .a .b .aa .bb
+4 -4
View File
@@ -14,10 +14,10 @@
. ./test-glue-functions
# this locale causes problems all over the place
if locale -a | grep -i '^zh_HK\.big5hkscs' >/dev/null ; then
if locale -a | grep -i '^zh_TW\.big5' >/dev/null ; then
:
else
echo "glob2.sub: warning: you do not have the zh_HK.big5hkscs locale installed;" >&2
echo "glob2.sub: warning: you do not have the zh_TW.big5 locale installed;" >&2
echo "glob2.sub: warning: that will cause some of these tests to fail." >&2
fi
@@ -41,7 +41,7 @@ esac
[[ $var = $var ]] && echo ok 4
[[ $var = $'ab\134' ]] && echo ok 5
LC_ALL=zh_HK.big5hkscs
LC_ALL=zh_TW.big5
read a b c <<< $'\u3b1 b c\n'
echo $b
@@ -62,4 +62,4 @@ printf "%s" "a${alpha}b" | LC_ALL=C od -b | _intl_normalize_spaces
a=$'\u3b1'
[[ $a = $a ]] && echo ok 6
LC_ALL=zh_HK.big5hkscs ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7
LC_ALL=zh_TW.big5 ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7
+1 -1
View File
@@ -15,7 +15,7 @@
TESTDIR=${TMPDIR}/glob-test-$$
mkdir ${TESTDIR}
cd $TESTDIR || {
cd -L $TESTDIR || {
echo "$TESTDIR: cannot cd" >&2
exit 1
}
+38 -3
View File
@@ -17,14 +17,18 @@ hi\
there
EO\
F
line 1line 2
hi
hi
nextEOF
tab 1
tab 2
tab 3
abc
def ghi
jkl mno
echo "
echo \"
fff is a function
fff ()
{
@@ -124,10 +128,41 @@ argv[3] = <ve>
foo bar
./heredoc7.sub: line 21: after: command not found
./heredoc7.sub: line 29: warning: here-document at line 29 delimited by end-of-file (wanted `EOF')
./heredoc7.sub: line 29: foobar: command not found
./heredoc7.sub: line 30: EOF: command not found
./heredoc7.sub: line 26: foobar: command not found
./heredoc7.sub: line 27: EOF: command not found
grep: *.c: No such file or directory
foo ()
{
echo begin;
if cat <<HERE
contents
HERE
then
echo 1 2;
echo 3 4;
fi
}
foo ()
{
echo begin;
while read var <<HERE
contents
HERE
do
echo 1 2;
echo 3 4;
done
}
hello
world
hello
world
here-doc line 1
here-doc line 2
here-document
here-document
comsub here-string
./heredoc.tests: line 156: warning: here-document at line 154 delimited by end-of-file (wanted `EOF')
./heredoc.tests: line 184: warning: here-document at line 181 delimited by end-of-file (wanted `')
hi
there
''
+34 -6
View File
@@ -80,6 +80,12 @@ F
EOF
true
# but unquoted here-documents remove backslash-newline
cat <<EOF
line 1\
line 2
EOF
# check that \newline is removed at start of here-doc
cat << EO\
F
@@ -92,6 +98,12 @@ hi
EO\
F
# backslash-newline processing is performed before the check for the delimiter
cat <<EOF
next\
EOF
EOF
# check operation of tab removal in here documents
cat <<- EOF
tab 1
@@ -100,16 +112,25 @@ cat <<- EOF
EOF
# check appending of text to file from here document
rm -f ${TMPDIR}/bash-zzz
cat > ${TMPDIR}/bash-zzz << EOF
rm -f ${TMPDIR}/bash-zzz-$$
cat > ${TMPDIR}/bash-zzz-$$ << EOF
abc
EOF
cat >> ${TMPDIR}/bash-zzz << EOF
cat >> ${TMPDIR}/bash-zzz-$$ << EOF
def ghi
jkl mno
EOF
cat ${TMPDIR}/bash-zzz
rm -f ${TMPDIR}/bash-zzz
cat ${TMPDIR}/bash-zzz-$$
rm -f ${TMPDIR}/bash-zzz-$$
# check behavior of double quotes and backslashes in here-documents
cat <<EOF
echo "
EOF
cat <<EOF
echo \"
EOF
# make sure command printing puts the here-document as the last redirection
# on the line, and the function export code preserves syntactic correctness
@@ -142,7 +163,13 @@ ${THIS_SH} ./heredoc6.sub
# interaction between here-documents and command substitutions
${THIS_SH} ./heredoc7.sub
${THIS_SH} ./heredoc8.sub
# various tests for printing here-documents in function bodies
${THIS_SH} ./heredoc9.sub
# test various combinations of here-documents and aliases
${THIS_SH} ./heredoc10.sub
echo $(
cat <<< "comsub here-string"
@@ -151,6 +178,7 @@ echo $(
# check that end of file delimits a here-document
# THIS MUST BE LAST!
cat << EOF
cat <<''
hi
there
''
+4
View File
@@ -148,6 +148,10 @@ echo four ; echo two
\!
\!
\!
1 hi 1
2 hi 0
!
!
a
b
c
+8
View File
@@ -34,3 +34,11 @@ echo "\!"
echo "$( echo '\!' )"
echo '\!'
# more stop characters post-bash-5.2
!; echo 1 hi $?
!& echo 2 hi $?
(echo !)
echo !>/dev/null
echo !</dev/null
+79 -4
View File
@@ -97,7 +97,7 @@ line 2 for history
6 HISTFILE=$TMPDIR/newhistory
7 echo displaying \$HISTFILE after history -a
8 cat $HISTFILE
./history.tests: line 90: fc: no command found
./history.tests: line 91: fc: no command found
15 echo line 2 for history
16 unset HISTSIZE
17 unset HISTFILE
@@ -107,7 +107,7 @@ echo xx xb xc
xx xb xc
echo 44 48 4c
44 48 4c
./history.tests: line 105: fc: no command found
./history.tests: line 106: fc: no command found
aa
bb
cc
@@ -140,9 +140,11 @@ three
one
two
three
5.2
(exit 42)
42
5.3
echo ${BASH_VERSION%\.*}
5.2
5.3
echo ${BASH_VERSION%\.*}
a
b
@@ -178,6 +180,8 @@ i
4 echo g
5 echo h
./history3.sub: line 48: history: @42: invalid number
./history3.sub: line 49: history: @42: numeric argument required
0
1
@@ -264,6 +268,22 @@ out of range 3
12 echo out of range 3
out of range 4
13 fc -l 1 99
a
b
c
# out of range specs aren't errors
echo a
a
d
e
1 echo a
2 echo b
3 echo c
4 # out of range specs aren't errors
5 # out of range specs aren't errors
6 echo a
7 echo d
8 echo e
1
2
3
@@ -297,3 +317,58 @@ out of range 4
7 echo 9
8 echo 10
5 echo 10
$ 1
$ 2
$ 3
$ exit
6
$ 1
$ 2
$ 3
$ 4
$ 5
$ exit
6
$ 1
$ 2
$ exit
4
$ e 1
$ e 2
$ e 3
$ exit
3
e 1
e 2
e 3
$ x 1
$ x 2
$ x 3
$ x 4
$ x 5
$ exit
3
x 3
x 4
x 5
$ y 1
$ y 2
$ exit
2
y 1
y 2
$ 1
$ 2
$ exit
0
a
b
c
d
1 echo a
2 echo c
3 echo d
4 history -d 2
5 history
./history8.sub: line 15: history: 72: history position out of range
./history8.sub: line 16: history: -72: history position out of range
+3
View File
@@ -50,6 +50,7 @@ history -s "echo line for history"
history
history -p '!!'
history -p # this succeeds silently
fc -nl
@@ -131,3 +132,5 @@ ${THIS_SH} ./history3.sub
${THIS_SH} ./history4.sub
${THIS_SH} ./history5.sub
${THIS_SH} ./history6.sub
${THIS_SH} ./history7.sub
${THIS_SH} ./history8.sub
+5
View File
@@ -26,3 +26,8 @@ three
history
fc -s cat
# try re-executing a failed command, check the exit status
(exit 42)
fc -s -1
echo $?
+3
View File
@@ -45,5 +45,8 @@ history -d 5-0xaf
history ; echo
history -d @42
history @42
unset HISTFILE
exit 0
+16
View File
@@ -54,4 +54,20 @@ fc -l 1 99
echo out of range 4
fc -l -20 -40
HISTSIZE=10
history -c
echo a
echo b
echo c
# out of range specs aren't errors
fc -e - 48
fc -s -- -42
echo d
echo e
fc -l
unset HISTFILE # suppress writing history file
+11 -1
View File
@@ -21,7 +21,7 @@ aéb
bytematch
0000000 254 012
0000002
Passed all 1378 Unicode tests
Passed all 1770 Unicode tests
0000000 303 277 012
0000003
0000000 303 277 012
@@ -55,3 +55,13 @@ Passed all 1378 Unicode tests
$'5\247@3\231+\306S8\237\242\352\263'
+ : $'5\247@3\231+\306S8\237\242\352\263'
+ set +x
ಇಳಿಕೆಗಳು
ಇಳ
ಇಳ
ಇಳ
ಇಳ ---
ಇ ---
+2
View File
@@ -66,3 +66,5 @@ ${THIS_SH} ./unicode1.sub # 2>/dev/null
${THIS_SH} ./unicode2.sub
${THIS_SH} ./unicode3.sub 2>&1
${THIS_SH} ./intl4.sub
+25 -15
View File
@@ -33,17 +33,20 @@ i killed it
2: ok 3
127
./jobs5.sub: line 71: declare: wpid: not found
./jobs5.sub: line 74: wait: `invalid-varname': not a valid identifier
./jobs5.sub: line 76: wait: WV: cannot unset: readonly variable
child1 exit status 0
[1]+ Running sleep 20 &
./jobs7.sub: line 5: fg: no current jobs
[1]+ Running sleep 20 &
got USR1
0
./jobs.tests: line 40: wait: %1: no such job
./jobs.tests: line 45: fg: no job control
./jobs.tests: line 45: wait: %1: no such job
./jobs.tests: line 50: fg: no job control
wait-for-pid
wait-errors
./jobs.tests: line 58: wait: `1-1': not a pid or valid job spec
./jobs.tests: line 59: wait: `-4': not a pid or valid job spec
./jobs.tests: line 70: wait: `1-1': not a pid or valid job spec
./jobs.tests: line 71: wait: `-4': not a pid or valid job spec
wait-for-background-pids
async list wait-for-background-pids
async list wait for child
@@ -52,7 +55,7 @@ wait-when-no-children
posix jobs output
[1]+ Done sleep 1
wait-for-job
./jobs.tests: line 84: wait: %2: no such job
./jobs.tests: line 96: wait: %2: no such job
127
async list wait-for-job
forked
@@ -65,19 +68,20 @@ sleep 2
fg-bg 4
sleep 2
fg-bg 5
./jobs.tests: line 111: fg: %2: no such job
./jobs.tests: line 112: bg: job 1 already in background
./jobs.tests: line 123: fg: %2: no such job
./jobs.tests: line 124: bg: job 1 already in background
fg-bg 6
./jobs.tests: line 119: fg: -s: invalid option
./jobs.tests: line 131: fg: -s: invalid option
fg: usage: fg [job_spec]
./jobs.tests: line 120: bg: -s: invalid option
./jobs.tests: line 132: bg: -s: invalid option
bg: usage: bg [job_spec ...]
./jobs.tests: line 125: disown: -s: invalid option
./jobs.tests: line 137: disown: -s: invalid option
disown: usage: disown [-h] [-ar] [jobspec ... | pid ...]
./jobs.tests: line 129: disown: %1: no such job
./jobs.tests: line 132: disown: %2: no such job
./jobs.tests: line 141: disown: %1: no such job
./jobs.tests: line 144: disown: %2: no such job
./jobs.tests: line 147: disown: @12: no such job
wait-for-non-child
./jobs.tests: line 135: wait: pid 1 is not a child of this shell
./jobs.tests: line 150: wait: pid 1 is not a child of this shell
127
3 -- 1 2 3 -- 1 - 2 - 3
[1] Running sleep 300 &
@@ -87,8 +91,8 @@ running jobs:
[1] Running sleep 300 &
[2]- Running sleep 350 &
[3]+ Running sleep 400 &
./jobs.tests: line 152: kill: %4: no such job
./jobs.tests: line 154: jobs: %4: no such job
./jobs.tests: line 167: kill: %4: no such job
./jobs.tests: line 169: jobs: %4: no such job
current job:
[3]+ Running sleep 400 &
previous job:
@@ -118,3 +122,9 @@ done
after KILL -STOP, foregrounding %1
sleep 4
done
./jobs.tests: line 229: jobs: -q: invalid option
jobs: usage: jobs [-lnprs] [jobspec ...] or jobs -x command [args]
./jobs.tests: line 231: suspend: -z: invalid option
suspend: usage: suspend [-f]
./jobs.tests: line 232: suspend: cannot suspend: no job control
./jobs.tests: line 233: suspend: cannot suspend: no job control
+29 -5
View File
@@ -32,6 +32,11 @@ ${THIS_SH} ./jobs5.sub
${THIS_SH} ./jobs6.sub
${THIS_SH} ./jobs7.sub
# more disown -h tests
${THIS_SH} ./jobs8.sub
# wait interrupted by signal for which a trap has been set
${THIS_SH} ./jobs9.sub
jobs
echo $?
@@ -40,16 +45,23 @@ echo $?
wait %1
# make sure we can't fg a job started when job control was not active
sleep 30 &
sleep 20 &
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
kill -n9 $pid
wait $pid # make sure we reap the processes while stderr is still redirected
sleep 30 &
pid2=$!
kill -sHUP $pid2
wait $pid2
exec 2>&5
unset -v pid pid2
#
echo wait-for-pid
sleep 4 &
wait $!
@@ -131,6 +143,9 @@ disown %1
# this, however, is an error
disown %2
# this is definitely an error
disown -h @12
echo wait-for-non-child
wait 1
echo $?
@@ -205,5 +220,14 @@ kill -STOP %1
sleep 2 # give time for the shell to get the stop notification
echo after KILL -STOP, foregrounding %1
fg %1
echo done
# these are all errors
set +m
jobs -q
suspend -z
suspend
suspend --
+5
View File
@@ -69,3 +69,8 @@ echo $wpid $?
jobs
wait -p wpid
declare -p wpid
# let's check errors like with other builtins that take variable names
wait -p invalid-varname
readonly WV
wait -p WV
+1
View File
@@ -7,6 +7,7 @@ last = c
1 -- 0 0 1
1 -- 0 0 1
1 -- 0 1 0
1 42
lastpipe1.sub returns 14
A1
A2
+3
View File
@@ -65,6 +65,9 @@ echo $? -- ${PIPESTATUS[@]}
true | binfalse | true
echo $? -- ${PIPESTATUS[@]}
binfalse | true | true | VAR=42
echo $? $VAR
set +o pipefail
${THIS_SH} ./lastpipe1.sub
+1 -1
View File
@@ -190,7 +190,7 @@ argv[1] = <0>
./more-exp.tests: line 442: ${#=}: bad substitution
./more-exp.tests: line 444: ${#+}: bad substitution
./more-exp.tests: line 446: ${#1xyz}: bad substitution
./more-exp.tests: line 449: #: %: syntax error: operand expected (error token is "%")
./more-exp.tests: line 449: #: %: arithmetic syntax error: operand expected (error token is "%")
argv[1] = <0>
argv[1] = <a+b>
argv[1] = <+>
+25 -9
View File
@@ -92,6 +92,10 @@ expect <one>
one
expect <four>
four
expect <X>
X
expect <X>
X
errors = 0
1
2
@@ -123,17 +127,17 @@ bar
unset
./nameref8.sub: line 16: typeset: warning: v: circular name reference
./nameref8.sub: line 16: warning: v: circular name reference
./nameref8.sub: line 18: warning: v: circular name reference
./nameref8.sub: line 18: warning: v: maximum nameref depth (8) exceeded
inside
inside: two
outside:
./nameref8.sub: line 42: typeset: warning: x: circular name reference
./nameref8.sub: line 42: warning: x: circular name reference
./nameref8.sub: line 44: warning: x: circular name reference
./nameref8.sub: line 44: warning: x: maximum nameref depth (8) exceeded
foo
./nameref8.sub: line 51: typeset: warning: v: circular name reference
./nameref8.sub: line 51: warning: v: circular name reference
./nameref8.sub: line 51: warning: v: circular name reference
./nameref8.sub: line 51: warning: v: maximum nameref depth (8) exceeded
local
./nameref8.sub: line 60: typeset: v: nameref variable self references not allowed
./nameref8.sub: line 67: warning: x: circular name reference
@@ -302,7 +306,7 @@ declare -n ref="var"
declare -a a=([0]="0")
./nameref15.sub: line 14: local: warning: a: circular name reference
./nameref15.sub: line 14: warning: a: circular name reference
./nameref15.sub: line 14: warning: a: circular name reference
./nameref15.sub: line 14: warning: a: maximum nameref depth (8) exceeded
declare -a a=([0]="X")
declare -a b=([0]="X")
./nameref15.sub: line 14: local: warning: a: circular name reference
@@ -311,14 +315,14 @@ declare -a b=([0]="X")
declare -a b=([0]="0")
./nameref15.sub: line 32: typeset: warning: ref: circular name reference
./nameref15.sub: line 32: warning: ref: circular name reference
./nameref15.sub: line 33: warning: ref: circular name reference
./nameref15.sub: line 33: warning: ref: maximum nameref depth (8) exceeded
./nameref15.sub: line 34: warning: ref: circular name reference
inside X
outside X
before: 7
./nameref15.sub: line 45: typeset: warning: xxx: circular name reference
./nameref15.sub: line 45: warning: xxx: circular name reference
./nameref15.sub: line 46: warning: xxx: circular name reference
./nameref15.sub: line 46: warning: xxx: maximum nameref depth (8) exceeded
declare -n xxx="xxx"
./nameref15.sub: line 48: warning: xxx: circular name reference
xxx_func: inside: xxx = foo
@@ -529,17 +533,18 @@ declare -a array=([0]="zero")
declare -a array=([0]="one" [1]="two" [2]="three")
declare -ai a=([0]="5")
declare -ai a=([0]="6")
declare -ai a=([0]="42")
declare -ai a=([0]="1")
./nameref23.sub: line 15: declare: b: not found
./nameref23.sub: line 16: declare: b: not found
declare -ai a=([0]="1")
declare -- b="1"
declare -ai a=([0]="1")
declare -- b="11"
declare -ai a=([0]="1")
declare -- b="110"
./nameref23.sub: line 25: declare: `1': invalid variable name for name reference
./nameref23.sub: line 26: declare: `1': invalid variable name for name reference
declare -ai a=([0]="1")
./nameref23.sub: line 27: declare: b: not found
./nameref23.sub: line 28: declare: b: not found
declare -ai a=([0]="4")
declare -in b="a[0]"
declare -ai a=([0]="6")
@@ -558,3 +563,14 @@ declare -ai a=([0]="0" [1]="16")
12
16
declare -ai a=([0]="0" [1]="16")
./nameref24.sub: line 24: declare: `': not a valid identifier
./nameref24.sub: line 25: declare: `a&b': invalid variable name for name reference
3
3
0
0
0
./nameref24.sub: line 38: declare: `aa&bb': invalid variable name for name reference
3
3
5
+1
View File
@@ -5,6 +5,7 @@ declare -n b='a[0]'
b+=1 ; declare -p a
declare b+=1 ; declare -p a
declare b=42 ; declare -p a
unset a b
unset -n b
+14
View File
@@ -228,6 +228,20 @@ echo "expect <four>"
echo $qux
ckval qux ${bar[3]}
bar=()
declare -n ref='bar[1]'
echo "expect <X>"
echo ${ref=X}
ckval ref ${bar[1]}
unset -n ref
declare -n ref
echo "expect <X>"
echo ${ref=X}
ckval ref ${ref}
# Need to add code and tests for `for' loop nameref variables
echo errors = $errors
+25 -16
View File
@@ -3,7 +3,7 @@ argv[1] = <foo>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
./new-exp.tests: line 41: HOME: }: syntax error: operand expected (error token is "}")
./new-exp.tests: line 41: HOME: }: arithmetic syntax error: operand expected (error token is "}")
unset
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
@@ -59,6 +59,7 @@ argv[1] = <4>
argv[1] = <op>
argv[1] = <abcdefghijklmnop>
argv[1] = <abcdefghijklmnop>
./new-exp.tests: line 189: bad-var: invalid variable name
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
@@ -66,8 +67,8 @@ argv[4] = <d>
argv[1] = <a>
argv[2] = <b c>
argv[3] = <d>
./new-exp.tests: line 197: ABX: unbound variable
./new-exp.tests: line 201: $6: cannot assign in this way
./new-exp.tests: line 202: ABX: unbound variable
./new-exp.tests: line 206: $6: cannot assign in this way
argv[1] = <xxcde>
argv[1] = <axxde>
argv[1] = <abxyz>
@@ -176,7 +177,7 @@ a
./new-exp2.sub: line 62: 1111111111111111111111: command not found
argv[1] = <6>
./new-exp.tests: line 302: ${#:}: bad substitution
./new-exp.tests: line 307: ${#:}: bad substitution
argv[1] = <'>
argv[1] = <">
argv[1] = <"hello">
@@ -411,13 +412,13 @@ argv[6] = <w>
argv[7] = <x>
argv[8] = <y>
argv[9] = <z>
./new-exp.tests: line 520: $9: unbound variable
./new-exp.tests: line 521: 9: unbound variable
./new-exp.tests: line 522: UNSET: unbound variable
./new-exp.tests: line 523: UNSET: unbound variable
./new-exp.tests: line 524: UNSET: unbound variable
./new-exp.tests: line 525: UNSET: unbound variable
./new-exp.tests: line 526: UNSET: unbound variable
./new-exp.tests: line 525: $9: unbound variable
./new-exp.tests: line 526: 9: unbound variable
./new-exp.tests: line 527: UNSET: unbound variable
./new-exp.tests: line 528: UNSET: unbound variable
./new-exp.tests: line 529: UNSET: unbound variable
./new-exp.tests: line 530: UNSET: unbound variable
./new-exp.tests: line 531: UNSET: unbound variable
argv[1] = <5>
argv[1] = <#>
argv[1] = <#>
@@ -464,7 +465,7 @@ Case05---3---A:B:C---
Case06---1---A B C::---
Case07---3---A:B:C---
Case08---3---A:B:C---
./new-exp.tests: line 546: ${$(($#-1))}: bad substitution
./new-exp.tests: line 551: ${$(($#-1))}: bad substitution
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
@@ -481,8 +482,8 @@ argv[1] = <a>
argv[1] = <a>
argv[2] = <b>
argv[1] = <>
./new-exp.tests: line 565: $(($# - 2)): substring expression < 0
./new-exp.tests: line 567: -2: substring expression < 0
./new-exp.tests: line 570: $(($# - 2)): substring expression < 0
./new-exp.tests: line 572: -2: substring expression < 0
argv[1] = <bin>
argv[2] = <bin>
argv[3] = <ucb>
@@ -625,13 +626,13 @@ bash: line 1: ${x@C}: bad substitution
<'ab cd'>
<'4'> <'ab cd'>
<>
argv[1] = <host(2)[5.2]$ >
<
>
<' \t\n'>
<
>
<$' \t\n'>
$'\001\001'
declare -r x='ab '\''cd'\'' ef'
set -- 'ab' 'cd ef' '' 'gh'
declare -a A=([0]="ab" [1]="cd ef" [2]="" [3]="gh")
@@ -648,7 +649,15 @@ i
declare -i foo
A
declare -A foo
./new-exp10.sub: line 118: ${V@}: bad substitution
LOWER
Lower
argv[1] = <host(2)[5.3]$ >
argv[1] = <~$ >
argv[1] = <^A[0]~$ >
argv[1] = <^A^G^B[0:1]~\$ >
argv[1] = </ bash$ >
argv[1] = <1^J/ bash$ >
./new-exp10.sub: line 153: ${V@}: bad substitution
abcxxxdef
abcådef
ḅć
+5
View File
@@ -184,6 +184,11 @@ recho ${a-$z}
expect nothing
recho ${!1-$z}
expect an error
v=bad-var
echo ${!v}
unset -v v
set -- a 'b c' d
unset foo
foo=@
+42 -7
View File
@@ -42,13 +42,6 @@ printf "<%s> " "${z@Q}" ; echo # empty string?
recho ${z@Q} # this disappears
#
HOST=host
SHELL_LEVEL=2
NPS1='\[\]${HOST}($SHELL_LEVEL)[\v]\$ '
recho "${NPS1@P}"
#
D=' \t\n'
printf "<%s>" "${D@E}" ; echo
@@ -58,6 +51,10 @@ E=$' \t\n'
printf "<%s>" "${E@E}" ; echo
printf "<%s>" "${E@Q}" ; echo
v=$'\1\1'
printf '%q\n' "${v@E}"
unset -v v
declare x
declare -r x="ab 'cd' ef"
printf "%s" "${x@A}" ; echo
@@ -114,5 +111,43 @@ echo ${foo@a}
declare -p foo
unset -v foo
foo=lower
echo ${foo@U}
echo ${foo@u}
# framework for testing prompt expansions using @P transformation
cd /tmp
HOST=host
SHELL_LEVEL=2
HOME=$PWD
NPS1='\[\]${HOST}($SHELL_LEVEL)[\v]\$ '
recho "${NPS1@P}"
NPS1='\[\]\W\$\040'
recho "${NPS1@P}"
NPS1='\[\001\][\j]\w\$\040'
recho "${NPS1@P}"
NPS1='\[\a\][\j:\!]\w\\\$\040'
set -o emacs
recho "${NPS1@P}"
set +o emacs
cd /
# no longer abbreviate as ~
NPS1='\W \s\$\040'
recho "${NPS1@P}"
set -o posix
NPS1='!\n\W \s\$\040'
recho "${NPS1@P}"
cd $OLDPWD
# this must be last, fatal error
V=42
echo ${V@} # error
+1
View File
@@ -1,3 +1,4 @@
bash: -c: line 1: unexpected EOF while looking for matching `)'
AAA
bash5: line 1: `invalid-name': not a valid identifier
in
+10
View File
@@ -1,5 +1,15 @@
# catch-all for parsing problems that don't fit anywhere else
# word_top issues in bash-5.2
case x in x) if ((1)); then :; fi ;; esac
case x in x) if ((1)); then :; fi esac
case x in x) if ((true ) ); then :; fi ;; esac
case x in x) if ((true ) ); then :; fi esac
# problem with bash-5.2
${THIS_SH} -c '((X=([))]' bash
# this has to be in a separate file to get desired EOF behavior
${THIS_SH} ./parser1.sub
+4
View File
@@ -39,3 +39,7 @@ a
real 0.00
user 0.00
sys 0.00
real 0.00
user 0.00
sys 0.00
4
+7
View File
@@ -54,3 +54,10 @@ echo $?
echo $?
time -p -- echo a
time -- :
# this should print timing information
. ./test-glue-functions
${THIS_SH} -c '{ time; echo after; }' |& wc -l | _cut_leading_spaces
+119 -12
View File
@@ -1,5 +1,10 @@
printf: usage: printf [-v var] format [arguments]
printf: usage: printf [-v var] format [arguments]
./printf.tests: line 26: printf: -x: invalid option
printf: usage: printf [-v var] format [arguments]
./printf.tests: line 29: printf: `invalid-var': not a valid identifier
abc
./printf.tests: line 30: printf: `invalid-var': not a valid identifier
10
one
one\ctwo
@@ -13,6 +18,11 @@ unquoted
unquoted quoted
unquoted quoted
this\&that
echo a\\;ls
echo a\'\;ls
echo 'a'\''b'\;ls
\*
\*
1 2 3 4 5
onestring 0 0 0
onestring 0 0 0.00
@@ -30,7 +40,7 @@ A7
--\"abcd\"--
--\'abcd\'--
--a\x--
./printf.tests: line 95: printf: missing hex digit for \x
./printf.tests: line 115: printf: missing hex digit for \x
--\x--
----
----
@@ -91,12 +101,12 @@ A7
26
26
26
./printf.tests: line 219: printf: `%10': missing format character
./printf.tests: line 220: printf: `M': invalid format character
ab./printf.tests: line 223: printf: `y': invalid format character
./printf.tests: line 226: printf: GNU: invalid number
./printf.tests: line 239: printf: `%10': missing format character
./printf.tests: line 240: printf: `M': invalid format character
ab./printf.tests: line 243: printf: `y': invalid format character
./printf.tests: line 246: printf: GNU: invalid number
0
./printf.tests: line 227: printf: GNU: invalid number
./printf.tests: line 247: printf: GNU: invalid number
0
-
(foo )(bar )
@@ -149,6 +159,16 @@ b
xx
xx
< >< >
0
^@
0
0.00
''
''
./printf.tests: line 364: printf: 9223372036854775825: Result too large
9223372036854775807
./printf.tests: line 365: printf: -9223372036854775815: Result too large
-9223372036854775808
one
one\ctwo
4\.2
@@ -161,6 +181,8 @@ unquoted
unquoted quoted
unquoted quoted
this\&that
'no-quotes-needed'
'quotes;needed'
1 2 3 4 5
onestring 0 0 0
onestring 0 0 0.00
@@ -174,7 +196,7 @@ A7
--\"abcd\"--
--\'abcd\'--
--a\x--
./printf1.sub: line 107: printf: missing hex digit for \x
./printf1.sub: line 111: printf: missing hex digit for \x
--\x--
----
----
@@ -235,12 +257,12 @@ A7
26
26
26
./printf1.sub: line 293: printf: `%10': missing format character
./printf1.sub: line 294: printf: `M': invalid format character
./printf1.sub: line 297: printf: `y': invalid format character
./printf1.sub: line 300: printf: GNU: invalid number
./printf1.sub: line 297: printf: `%10': missing format character
./printf1.sub: line 298: printf: `M': invalid format character
./printf1.sub: line 301: printf: `y': invalid format character
./printf1.sub: line 304: printf: GNU: invalid number
0
./printf1.sub: line 302: printf: GNU: invalid number
./printf1.sub: line 306: printf: GNU: invalid number
0
-
(foo )(bar )
@@ -296,3 +318,88 @@ x +123x
x +123x
x +123x
x +123x
abcd
ab
123
123
173
7b
7B
hello
hello
123
6
123 --
123 --
173 --
7b --
7B --
hello --
hello --
123 --
6 --
0000000 000
0000001
0000000 000
0000001
0000000 340 262 207 340 262 263 340 262 277 340 262 225 340 263 206 340
0000010 262 227 340 262 263 340 263 201 012
0000019
0000000 340 262 207 340 262 263 012
0000007
0000000 340 262 207 012
0000004
0000000 340 262 207 340 262 263 012
0000007
0000000 040 040 340 262 207 340 262 263 012
0000009
0000000 340 262 207 340 262 263 040 040 055 055 055 012
000000c
0000000 340 262 207 012
0000004
0000000 340 262 207 012
0000004
0000000 340 262 207 012
0000004
0000000 340 262 207 012
0000004
0000000 040 040 040 340 262 207 012
0000007
0000000 340 262 207 040 040 040 055 055 055 012
000000a
[][]
./printf7.sub: line 19: printf: 21474836470: Result too large
[]
./printf7.sub: line 20: printf: 21474836470: Result too large
[X]
./printf7.sub: line 22: printf: 21474836470: Result too large
VAR=[]
./printf7.sub: line 25: printf: 21474836470: Result too large
VAR=[X]
./printf7.sub: line 31: printf: 9223372036854775825: Result too large
[]
./printf7.sub: line 32: printf: 9223372036854775825: Result too large
[X]
./printf7.sub: line 34: printf: 9223372036854775825: Result too large
VAR=[]
./printf7.sub: line 37: printf: 9223372036854775825: Result too large
VAR=[X]
./printf7.sub: line 43: printf: 21474836470: Result too large
[]
./printf7.sub: line 44: printf: 21474836470: Result too large
[X]
./printf7.sub: line 46: printf: 21474836470: Result too large
VAR=[]
./printf7.sub: line 49: printf: 21474836470: Result too large
VAR=[X]
./printf7.sub: line 55: printf: 9223372036854775825: Result too large
[]
./printf7.sub: line 56: printf: 9223372036854775825: Result too large
[X]
./printf7.sub: line 58: printf: 9223372036854775825: Result too large
VAR=[]
./printf7.sub: line 61: printf: 9223372036854775825: Result too large
VAR=[X]
XY
./printf7.sub: line 71: printf: 9223372036854775825: Result too large
XY
+44 -3
View File
@@ -22,6 +22,13 @@ printf --
printf ""
printf -- ""
# this is an error
printf -x
# these are errors
printf -v invalid-var 'abc\n'
printf '%s\n%n' abc invalid-var
# in the future this may mean to put the output into VAR, but for
# now it is an error
# 2005-03-15 no longer an error
@@ -60,6 +67,19 @@ printf "%s%10q\n" unquoted quoted
printf "%q\n" 'this&that'
# %Q is like %q but treats the precision differently
S="a'b"
S1="${S@Q}"
T=';ls'
printf 'echo %.2q%q\n' "$S" "$T"
printf 'echo %.2Q%Q\n' "$S" "$T" # note the difference
# a different way to do it
printf 'echo %.*s%q\n' ${#S1} "$S1" "$T"
printf '%.1Q\n' '**'
printf '%.*Q\n' 1 '**'
# make sure the format string is reused to use up arguments
printf "%d " 1 2 3 4 5; printf "\n"
@@ -324,11 +344,32 @@ printf -v var "%b" @(hugo); echo "x${var}x"
# make sure that missing arguments are always handled like the empty string
printf "<%3s><%3b>\n"
# other format specifiers with missing arguments
# 0
printf '%d\n'
# null char
printf '%c\n'
printf '%x\n'
printf '%4.2f\n'
printf '%b'
printf '%q\n'
printf '%Q\n'
# let's test some out-of-range integer errors for POSIX-specified behavior
TOOBIG=9223372036854775825
TOOSMALL=-9223372036854775815
printf '%d\n' "$TOOBIG"
printf '%d\n' "$TOOSMALL"
# tests variable assignment with -v
${THIS_SH} ./printf1.sub
${THIS_SH} ./printf2.sub
${THIS_SH} ./printf3.sub
${THIS_SH} ./printf4.sub
${THIS_SH} ./printf5.sub
# multibyte characters with %ls/%S and %lc/%C
${THIS_SH} ./printf6.sub
${THIS_SH} ./printf7.sub
+7 -3
View File
@@ -60,6 +60,10 @@ printf "%s" "$vv"
printf -v vv "%q\n" 'this&that'
printf "%s" "$vv"
# altform with %q will force single-quoting
printf -v vv '%#q\n' no-quotes-needed 'quotes;needed'
printf "%s" "$vv"
# make sure the format string is reused to use up arguments
printf -v vv "%d " 1 2 3 4 5
printf "%s" "$vv"
@@ -158,7 +162,7 @@ printf "%s" "$vv"
printf -v vv "%*b\n" 6 4.4BSD
printf "%s" "$vv"
# we handle this crap with homemade code in printf -v vv.def
# we handle this crap with homemade code in printf
printf -v vv "%10b\n" 4.4BSD
printf "%s" "$vv"
printf -v vv -- "--%-10b--\n" 4.4BSD
@@ -224,7 +228,7 @@ printf "%s" "$vv"
printf -v vv "%6.2g\n" 4.2
printf "%s" "$vv"
# test some of the more esoteric features of POSIX.1 printf -v vv
# test some of the more esoteric features of POSIX.1 printf
printf -v vv "%d\n" "'string'"
printf "%s" "$vv"
printf -v vv "%d\n" '"string"'
@@ -293,7 +297,7 @@ printf "%s" "$vv"
printf -v vv "%10"
printf -v vv "ab%Mcd\n"
# this caused an infinite loop in older versions of printf -v vv
# this caused an infinite loop in older versions of printf
printf -v vv "%y" 0
# these should print a warning and `0', according to POSIX.2
+2
View File
@@ -72,6 +72,8 @@ string \
string \
string \
string \}
escape\
escape\
'weferfds'\''dsfsdf'
'weferfdsdsfsdf'
'weferfds'\''dsfsdf'
+7
View File
@@ -133,6 +133,13 @@ echo ${foo:-'string \'}
echo "${foo:-string \\}"
echo ${foo:-string \\\}}
: ${TMPDIR:=/tmp}
${THIS_SH} -c 'echo escape\'
printf 'echo escape\' > $TMPDIR/quote-$$
${THIS_SH} $TMPDIR/quote-$$
rm -f $TMPDIR/quote-$$
${THIS_SH} ./quote1.sub
${THIS_SH} ./quote2.sub
${THIS_SH} ./quote3.sub
+8 -8
View File
@@ -1,9 +1,9 @@
declare -A assoc=(["x],b[\$(echo uname >&2)"]="1" )
declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="1" )
declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="2" )
./quotearray.tests: line 31: ((: 'assoc[x\],b\[\$(echo uname >&2)]++' : syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]++' ")
./quotearray.tests: line 31: ((: 'assoc[x\],b\[\$(echo uname >&2)]++' : arithmetic syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]++' ")
declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="2" )
./quotearray.tests: line 34: ((: 'assoc[x\],b\[\$(echo uname >&2)]'++ : syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]'++ ")
./quotearray.tests: line 34: ((: 'assoc[x\],b\[\$(echo uname >&2)]'++ : arithmetic syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]'++ ")
declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="2" )
declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="3" )
4
@@ -24,14 +24,14 @@ declare -a a=([0]="12" [1]="42")
declare -Ai assoc=(["']"]="3" ["\$var"]="1" )
105
declare -A assoc=(["\` echo >&2 foo\`"]="42" ["\$( echo >&2 bar)"]="63" )
./quotearray.tests: line 140: x],b[$(echo uname >&2): syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
./quotearray.tests: line 144: x],b[$(echo uname >&2): syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
./quotearray.tests: line 140: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
./quotearray.tests: line 144: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
1
./quotearray.tests: line 147: x],b[$(echo uname >&2): syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
./quotearray.tests: line 147: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
1
./quotearray.tests: line 150: x],b[$(echo uname >&2): syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
./quotearray.tests: line 150: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
1
./quotearray.tests: line 153: x],b[$(echo uname >&2): syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
./quotearray.tests: line 153: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)")
1
declare -A assoc
0
@@ -44,7 +44,7 @@ declare -A assoc=(["\` echo >&2 foo\`"]="128" [0]="0" ["]"]="12" ["x],b[\$(echo
foo
0
0
./quotearray1.sub: line 68: 0\],b\[1: syntax error: invalid arithmetic operator (error token is "\],b\[1")
./quotearray1.sub: line 68: 0\],b\[1: arithmetic syntax error: invalid arithmetic operator (error token is "\],b\[1")
declare -a array
0
0
+9
View File
@@ -9,6 +9,8 @@ a.
-\ a b\-
-\-a b\-
-\ a b\-
argv[1] = <abc>
argv[1] = <abc\>
argv[1] = <^A>
argv[1] = <^A>
argv[1] = <^?>
@@ -29,6 +31,8 @@ argv[1] = < foo>
argv[1] = <foo>
argv[1] = <foo>
argv[1] = < foo>
./read.tests: line 101: b: readonly variable
a = a b = c = stat = 2
a = abcdefg
xyz
a = xyz
@@ -43,6 +47,7 @@ unset or null 3
./read2.sub: line 45: read: -3: invalid timeout specification
1
abcde
abcde
abcde
./read3.sub: line 17: read: -1: invalid number
@@ -51,6 +56,7 @@ defg
ab
abc
#
0
while read -u 3 var
do
echo "$var"
@@ -83,3 +89,6 @@ one
two three four
one
two three four
IFS=[,] var=[abc] rest=[def,ghi]
IFS=[] var=[abc] rest=[def,ghi]
IFS=[ ] var=[ abc] rest=[def,ghi ]
+19
View File
@@ -26,6 +26,10 @@ echo "\ a b\ " | ( read -r x ; echo -"$x"- )
echo " \ a b\ " | ( read -r x y ; echo -"$x"-"$y"- )
echo " \ a b\ " | ( read -r x ; echo -"$x"- )
# input ending in backslash
printf 'abc\' | { read var ; recho "$var"; }
printf 'abc\' | { read -r var ; recho "$var"; }
# make sure that CTLESC and CTLNUL are passed through correctly
echo $'\001' | ( read var ; recho "$var" )
echo $'\001' | ( read ; recho "$REPLY" )
@@ -92,6 +96,15 @@ echo " foo" | { IFS=$' \t\n' ; read line; recho "$line"; }
echo " foo" | { IFS=$':' ; read line; recho "$line"; }
# this leaves `b' readonly
readonly b
read a b c <<EOF
a b c
EOF
# the latest POSIX draft says $? should be > 1
echo a = $a b = $b c = $c stat = $?
# test read -d delim behavior
${THIS_SH} ./read1.sub
@@ -115,3 +128,9 @@ ${THIS_SH} ./read7.sub
# test behavior of read -n and read -d on regular files
${THIS_SH} ./read8.sub
# test behavior of trailing IFS whitespace - POSIX conformance
${THIS_SH} ./read9.sub
# test behavior of read builtin modifying $IFS
${THIS_SH} ./read10.sub

Some files were not shown because too many files have changed in this diff Show More