[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
'mapfile -O1 array' breaks '[[ -v array ]]'
From: |
Wiley Young |
Subject: |
'mapfile -O1 array' breaks '[[ -v array ]]' |
Date: |
Mon, 17 Apr 2023 10:23:17 -0700 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -O2 -flto=auto -ffat-lto-objects -fexceptions -g
-grecord-g>
uname output: Linux localhost-live 6.0.7-301.fc37.x86_64 #1 SMP
PREEMPT_DYNAMIC>
Machine Type: x86_64-redhat-linux-gnu
Bash Version: 5.1
Patch Level: 16
Release Status: release
Description:
When an array 'a_foo' is created with 'mapfile -d '' -t', it is
tested with '[[ -v a_foo ]]' and '[[' returns 0. When '-O 1' is added to
mapfile, '[[ -v a_foo ]]' returns non-0.
Repeat-By: In test 3, when declare shows array "y" exists and has indices
beginning at 1, "[[ -v" shows array "y" doesn't exist.
I=1
for AB in '' "-O1"; do
for CD in '' a_quux; do
:;:;:
printf '\nloop %d\n' $(( I++ ))
unset a_quux a_foo
a_quux=( x y z )
mapfile -d '' $AB -t a_foo < <( printf '%s\0' "${a_quux[@]}" )
[[ $CD == a_quux ]] && a_foo+=( [0]=workaround )
declare -p a_foo
[[ -v a_foo ]]
printf 'exit: "[[ -v": %d\n' $?
done
done
Thanks,
Wiley
- 'mapfile -O1 array' breaks '[[ -v array ]]',
Wiley Young <=