[yocto] some shell script stylisms
Robert P. J. Day
rpjday at crashcourse.ca
Fri Jun 15 04:53:26 PDT 2012
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
EXT=${filename##*.}
* what's with the slashes in the "case" pattern matching?
case /$EXT/ in
/bin/)
# A file ending in .bin is a kernel
[ -z "$KERNEL" ] && KERNEL=$filename || \
error "conflicting KERNEL args [$KERNEL] and [$filename]"
;;
/ext[234]/|/jffs2/|/btrfs/)
... 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 ...
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
More information about the yocto
mailing list