some shell script stylisms

Robert P. J. Day

as i claw my way through the QEMU stuff in yocto, some pedantic
thoughts on how to make the shell scripts more readable, so more
observations from the "runqemu" script.

* all those multiple "echo" lines would look a lot nicer if replaced
by a single "here document", don't you think?

* extracting the filename extension doesn't need a pipe and an
invocation of "awk". how about just


* what's with the slashes in the "case" pattern matching?

case /$EXT/ in
# A file ending in .bin is a kernel
[ -z "$KERNEL" ] && KERNEL=$filename || \
error "conflicting KERNEL args [$KERNEL] and [$filename]"
... snip ...

is there something weird about slashes in case pattern matching
i've never seen? it's certainly not used later:

case "$arg" in
"qemux86" | "qemux86-64" | "qemuarm" | "qemumips" | "qemumips64" | "qemush4" | "qemuppc")
[ -z "$MACHINE" ] && MACHINE=$arg || \
error "conflicting MACHINE types [$MACHINE] and [$arg]"
"ext2" | "ext3" | "jffs2" | "nfs" | "btrfs")
... snip ...

where those "ext?" patterns could be combined the way they were
earlier. or, again, is there something subtle happening here i'm just
not seeing?

back to work ...



Robert P. J. Day Ottawa, Ontario, CANADA


Join { to automatically receive all group messages.