On 03/13/2012 11:03 AM, dethrophes wrote:
> 
> the missing "" in the case isn't redundant.

It is too redundant; you only need "" after case if the parser would
otherwise see two words before in.

> case "$HOME" in
>    *[^/]* ) HOME=${HOME%${HOME##*[^/]}} ;;
>    / | // ) ;;
>    *) HOME=/ ;; # //+(/)
> esac

By the way, one more tweak to make this example POSIX-compliant rather
than relying on a bash extension - shell pattern matching uses ! for
negation and leaves ^ unspecified (as an extension, bash treats ^ as a
synonym for ! in performing negation, but other shells treat ^
literally).  Additionally, since POSIX requires tilde-expansion to occur
on the word after 'case', you can write this as:

case ~ in
  *[!/]* ) HOME=${HOME%${HOME##*[!/]}} ;;
  / | // ) ;;
  *) HOME=/ ;;
esac

-- 
Eric Blake   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to