FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 11-20-2007, 06:24 AM
Vineet Kumar
 
Default QA needed for insecure LD_LIBRARY_PATH in many wrapper scripts

* Stefan Fritsch (sf@debian.org) [071116 13:03]:
> is unset. (Actually, some scripts use "${LD_LIBRARY_PATH+:
> $LD_LIBRARY_PATH}", which seems to work, too. But this is not
> documented in the bash man page, at least I can't find it.)

The difference between ${PARAMETER:+WORD} and ${PARAMETER+WORD} is
subtle, and you're right, it's not documented in the bash man page.
It is part of the POSIX shell standard, though. ${PARAMETER:+WORD}
substitutes WORD if PARAMETER is set and non-empty. ${PARAMETER+WORD}
substitutes WORD if PARAMETER is set, empty or not. For example:

vineet@sprocket:~$ FOO=
vineet@sprocket:~$ echo ${FOO+BAR}
BAR
vineet@sprocket:~$ echo ${FOO:+BAR}

vineet@sprocket:~$ unset FOO
vineet@sprocket:~$ echo ${FOO+BAR}

vineet@sprocket:~$ echo ${FOO:+BAR}

vineet@sprocket:~$

In many cases they'll be equivalent, but in the LD_LIBRARY_PATH case,
I'd recommend using the colon-form. If someone has set an empty
LD_LIBRARY_PATH, the correct behavior is just to add the directory you
want; you don't want to stick an extra empty pathname component in
there.

good times,
Vineet

--
http://www.doorstop.net/
--
"As we enjoy great advantages from inventions of others, we should be glad
of an opportunity to serve others by any invention of ours; and this we
should do freely and generously." --Benjamin Franklin
 
Old 11-20-2007, 07:18 AM
Vincent Danjean
 
Default QA needed for insecure LD_LIBRARY_PATH in many wrapper scripts

Vineet Kumar wrote:
> * Stefan Fritsch (sf@debian.org) [071116 13:03]:
>> is unset. (Actually, some scripts use "${LD_LIBRARY_PATH+:
>> $LD_LIBRARY_PATH}", which seems to work, too. But this is not
>> documented in the bash man page, at least I can't find it.)
>
> The difference between ${PARAMETER:+WORD} and ${PARAMETER+WORD} is
> subtle, and you're right, it's not documented in the bash man page.

>From the bash manpage:
In each of the cases below, word is subject to tilde expansion, parame‐
ter expansion, command substitution, and arithmetic expansion. When
not performing substring expansion, bash tests for a parameter that is
unset or null; omitting the colon results in a test only for a parame‐
ter that is unset.

But I agree that I would not have found it if I did not know what to
search.

> It is part of the POSIX shell standard, though.

Yes, and posh has it. I prefer the formulation from the posh manpage:
In the above modifiers, the : can be omitted, in which case the
conditions only depend on name being set (as opposed to set and not
null). [...]

Vincent

--
Vincent Danjean GPG key ID 0x9D025E87 vdanjean@debian.org
GPG key fingerprint: FC95 08A6 854D DB48 4B9A 8A94 0BF7 7867 9D02 5E87
Unofficial pacakges: http://www-id.imag.fr/~danjean/deb.html#package
APT repo: deb http://perso.debian.org/~vdanjean/debian unstable main


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 02:21 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org