[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
General Associative Array problem -- Was: UUID as Array Keys strangely n
From: |
Robert White |
Subject: |
General Associative Array problem -- Was: UUID as Array Keys strangely not possible |
Date: |
Fri, 22 Feb 2019 11:23:37 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 |
Consider the script at the end of this email. It's effectively
impossible to get EEEE FFFF or GGGG to accept the various values.
Either that or I am doing something incredibly stupid.
(It took me a while to factor this down and try virtually every
workaround that would not involve writing external files.)
#!/bin/bash -f
# These three arrays never get values no matter what
typeset -A EEEE
typeset -A FFFF
typeset -A GGGG
typeset -A INLINE
typeset -A INFUNC
function testfunc() {
eval INFUNC=( $( blkid /dev/${RECORD[3]} -o export | sed -e 's;\\
;_;' -e 's;\(.*\)=;[\1]=;' ) )
echo "Trying: FFFF+=( [${INFUNC[UUID]}]=boo )"
eval FFFF+=( [${INFUNC[UUID]}]=boo )
}
tail --lines=+3 /proc/partitions | grep -v ram |
while read -a RECORD
do
echo "Trying /dev/${RECORD[3]}"
testfunc ${RECORD[3]}
VV=$( blkid /dev/${RECORD[3]} -o export | sed -e 's;\\ ;_;' -e
's;\(.*\)=;[\1]=;' )
eval INLINE=( ${VV} )
if [ ${INLINE[UUID]} ]
then
echo "Trying: EEEE[${INLINE[UUID]}]=boo"
eval EEEE[${INLINE[UUID]}]=boo
fi
echo "INLINE Keys: " "${!INLINE[@]}" = "${INLINE[@]}"
echo "INFUNC Keys: " "${!INFUNC[@]}" = "${INFUNC[@]}"
for AA
in "${!INLINE[@]}"
do
if [ ${AA} == UUID ]
then
echo "Trying: GGGG[${INLINE[$AA]}]=${INLINE[DEVNAME]}"
GGGG[${INLINE[$AA]}]=${INLINE[DEVNAME]}
fi
done
echo
done
echo "EEEE Keys: " "${!EEEE[@]}" = "${EEEE[@]}"
echo "FFFF Keys: " "${!FFFF[@]}" = "${FFFF[@]}"
echo "GGGG Keys: " "${!GGGG[@]}" = "${GGGG[@]}"
- General Associative Array problem -- Was: UUID as Array Keys strangely not possible,
Robert White <=