avoid executing unsafe functions if we get a terminating signal while handling SIGCHLD; reject attempts to modify some attributes for readonly variables; more changes for unlocked stdio functions; quoting fixes for uncommon cases where IFS = ^A and the word is not being split

This commit is contained in:
Chet Ramey
2024-02-20 09:53:58 -05:00
parent e1dd98a1db
commit cc51fb3c65
17 changed files with 293 additions and 49 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ 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 137: unset: ps1: not an array variable
./array.tests: line 141: declare: c: cannot destroy array variables in this way
./array.tests: line 141: declare: c: readonly variable
this of
this is a test of read using arrays
this test
+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")
+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
+43
View File
@@ -0,0 +1,43 @@
set aa bb cc -- dd ; f=$'\1' IFS=$f
recho "$f$*$f"
recho "$f--$f"
[[ $f$*$f == *$f--$f* ]] && echo ok 1
[[ $f$*$f == "$f--$f" ]] || echo ok 2
[[ ${f}${*}${f} == *$f--$f* ]] && echo ok 3
[[ $f$*$f == $f$*$f ]] && echo ok 4
[[ ${f}${*}${f} == $f$*$f ]] && echo ok 5
[[ $f$*$f == *--* ]] && echo ok 6
[[ $* == $* ]] && echo ok 7
[[ $* == ${*} ]] && echo ok 8
[[ $f == $f ]] && echo ok 9
[[ $f == ${f} ]] && echo ok 10
# now with f an array and $f -> ${f[0]}
set aa bb cc -- dd ; f=( $'\1' )
[[ $f$*$f == *$f--$f* ]] && echo ok 11
[[ ${f}${*}${f} == *$f--$f* ]] && echo ok 12
[[ $f$*$f == $f$*$f ]] && echo ok 13
[[ ${f}${*}${f} == $f$*$f ]] && echo ok 14
[[ $f$*$f == *--* ]] && echo ok 15
[[ $* == $* ]] && echo ok 16
[[ $* == ${*} ]] && echo ok 17
[[ $f == $f ]] && echo ok 18
[[ $f == ${f} ]] && echo ok 19
# now use an array instead of $*
A=( aa bb cc -- dd ); f=$'\1' IFS=$f
[[ $f${A[*]}$f == $f${A[*]}$f ]] && echo ok 20
[[ $f${A[*]}$f == *--* ]] && echo ok 21
[[ ${f}${A[*]}${f} == *$f--$f* ]] && echo ok 22
[[ ${f}${A[*]}${f} == $f${A[*]}$f ]] && echo ok 23
[[ ${A[*]} == ${A[*]} ]] && echo ok 24
+26
View File
@@ -742,3 +742,29 @@ 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