GNU bash バージョン 3.2.57 でdeclare
、配列変数を出力するための使用とnullglob
オプションの間で競合が発生しています。
これらの 2 つは非常に無関係のように思えますが、nullglob
有効になっている場合、これは意図的なものですか?
#!/bin/bash
test () {
local FOO="xyz"
local BAR=("one" "two" "three")
declare -p FOO
declare -a -p BAR
}
echo $(test)
shopt -s nullglob
echo $(test)
shopt -u nullglob
echo $(test)
出力:
declare -- FOO="xyz" declare -a BAR='([0]="one" [1]="two" [2]="three")'
declare -- FOO="xyz" declare -a
declare -- FOO="xyz" declare -a BAR='([0]="one" [1]="two" [2]="three")'
中央の行に注意してください。nullglob
が設定されている場合、宣言BAR
は発行されません。