> For the record, ": foo" is a not entirely uncommon alternative way to
> write comments in Bourne shell it's also the only way to squeeze a
> comment and a trailing ";;" onto a single line.

Wow, I've never seen that outside DOS.bat scripts, but yes, it does that.
You can't have a comment following the ";;" part?

> >       *[^:]:) PATH="$PATH:" ;;
>
> That isn't valid POSIX shell [...] So you need "*[!:]:" there.

Cool, I didn't know that.  Are most Bourne implementations compliant with
that?  I've dealt with a lot of Bourne and korn implementations and never
had a problem with [^x] before, nor had I ever seen "[!x]" .  The linked
clarification (IEEE Std 1003.1-2001, Section 9.3.5) seems a bit
unnecessary to me, but that's clearly not up for debate here.

> This mistake results in a regression. Using bash (it's possibly worth
> noting that dash doesn't implement a trailing colon in PATH correctly):

Dash does it correctly for me ...
  % dash
  $ mkdir /tmp/testpath
  $ cd /tmp/testpath
  $ echo '#!/bin/true' > testme
  $ chmod +x testme
  $ if PATH=/ testpath; then echo "yes to standard path"; fi
  $ if PATH=/: testpath; then echo "yes to test"; fi

I don't have relative paths in my $PATH, so the above code returned only
"yes to test" which means dash implements this correctly.


> Please fix this by changing the pattern to "*[!:]:", or back to the
> perfectly good and arguably clearer (if longer) code that was there
> before.

I'd argue for my alternative; nix the case statement and tack on an extra
colon to the end of $PATH when called on line 46, like:

   for ELEMENT in $PATH:; do

The corner cases where it loops an extra time should be extremely rare
and not time-consuming anyway.  This is much cleaner than my original
suggestion (and Colin's).

-Adam



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to