On Thu, 2005-04-07 at 19:56 -0500, Dan McGhee wrote:

> I also cannot mentally expand the expression
> $PATHVARIABLE="${!PATHVARIABLE:+:${!PATHVARIABLE}}"

Can't blame you - that's pretty ugly. I've seen (and written) worse
though, so let's break it down:

The exclamation marks are like a pointer - when you see the notation
!PATHVARIABLE, replace it with the value of $PATHVARIABLE. So if
$PATHVARIABLE was equal to the string "PATH", it would be as if the
following command was used instead (note the exclamation marks are
gone):

    $PATHVARIABLE="${PATH:+:${PATH}}"

Of course, the left side of the assignment has a dollar sign next to it,
so that also gets expanded. So now, you have:

    PATH="${PATH:+:${PATH}}"

That then becomes a simple case of the alternate value syntax, although
the presence of the second colon makes it look a bit more complicated.
Basically, if the variable named before the first colon is set, then it
replaces it with the value after the first colon, which would be the
string ":$PATH".

In short, it takes the variable named in $PATHVARIABLE, and if it's set
to something, prepends a colon.


Simon.

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to