On 2/22/19 4:17 PM, Eduardo Bustamante wrote:
On Fri, Feb 22, 2019 at 3:24 AM Robert White <rwh...@pobox.com> wrote:
(...)
tail --lines=+3 /proc/partitions | grep -v ram |
while read -a RECORD
do
(...)
eval EEEE[${INLINE[UUID]}]=boo
(...)
done
echo "EEEE Keys: " "${!EEEE[@]}" = "${EEEE[@]}"
echo "FFFF Keys: " "${!FFFF[@]}" = "${FFFF[@]}"
echo "GGGG Keys: " "${!GGGG[@]}" = "${GGGG[@]}"
The `while' loop executes in a subshell and you're not using
`lastpipe'. See: https://mywiki.wooledge.org/BashFAQ/024
As a general recommendation: when submitting bug reports, try to
simplify things as much as possible, e.g.:
* Replace the `blkid' command invokation with a `printf' (not everyone
has the same block devices, nor runs Linux)
* Replace `/proc/partitions' with a copy of its contents (again, not
everyone has the same files in their systems, makes it impossible to
reproduce what you're experiencing)
* Remove the FFFF and GGGG arrays, we only need a sample case to
understand what's going on, not three
* Remove the sed commands, you're going to be using static values
(`printf') anyways
* Does the `set -f' at the top of the file have any effect in the
outcome in this particular case? no? then remove it
* I think you get the idea.
Just to help you understand my perspective, this is what I see when I
try to troubleshoot your script (a bunch of errors), that doesn't
really help me help you:
dualbus@system76-pc:~$ shellcheck foo.sh
In foo.sh line 12:
function testfunc() {
^-- SC1009: The mentioned syntax error was in this function.
^-- SC1073: Couldn't parse this brace group. Fix
to allow more checks.
In foo.sh line 13:
eval INFUNC=( $( blkid /dev/${RECORD[3]} -o export | sed -e 's;\\
^-- SC1036: '(' is invalid here. Did you forget to escape it?
^-- SC1056: Expected a '}'. If you have one, try a ; or
\n in front of it.
^-- SC1072: Missing '}'. Fix any mentioned problems and
try again.
^-- SC1098: Quote/escape special characters when using
eval, e.g. eval "a=(b)".
Your syntax checker is straight tripping on that SC1036 error dude.
Array assignment using ARRAYNAME=( expression ) is completely legal and
correct with or without the eval. The structure even allows for line
continuation just like pipelines
ARRAYNAME=(
)
Same for the error emitted for using the "function" keyord
function somename() {
}
It does look like it got line-wrapped to death in the sed, but according
to my sent items directory that happened after it left here. So my bad
for lack of attachment.
I get your point for blkid and /proc/partitions. I was getting
frustrated since I'd tried all three forms of substitution I didn't know
if the function calls, the evaluation order, or the expansions were to
blame so I included all three contexts.
Turns out I've been doing the pipe-while-read thing blithely for a good
twenty years now (going back to the borne shell on SVR4) and never
thought about the pipeline itself.
So I was right, for stupid definitions of right, when I wondered if I
was missing something incredibly obvious. /sigh. 8-)
Thanks for all the help.
--Rob.