Jeff King [off-list ref] writes:
For some reason I had always assumed that complicated pattern matching
with "#" was non-POSIX, but I checked and it is definitely in there.
No, the offending code really dates back to the days back when I was
writing most of the shell scripts (or others were mostly copying
from what I have written). I had this irrational aversion against
variable substitutions that are beyond ${var-default}, ${var=assign}
and ${var+isset}.
The conversion looks fine (modulo one missed one you noticed).
Thanks for cleaning things up.