You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When IFS='', $@ is expanded with no white space between the elements instead of with white space which breaks word splitting. This simple program shows the issue:
res=0
sum() {
# implement callee-save calling convention using `set`# here, we save the value of $res after the function parametersset$@$res# $1 $2 $3 are now set
res=$(($1+$2))echo"$1 + $2 = $res"
res=$3# restore the value of $res
}
unset IFS
sum 12 30 # outputs "12 + 30 = 42"
IFS=''
sum 12 30 # outputs "12 + 30 = 42"
IFS=
sum 12 30 # outputs "1230 + 0 = 1230"set -u
IFS=
sum 12 30 # fails with "fatal: Undefined variable '2'" on res=$(($1 + $2))
The text was updated successfully, but these errors were encountered:
Bug
When
IFS=''
,$@
is expanded with no white space between the elements instead of with white space which breaks word splitting. This simple program shows the issue:The text was updated successfully, but these errors were encountered: