[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implicit linking of local .so



On Wed, 1 Dec 1999, Steve Baker wrote:

> > > #! /bin/sh
> > >
> > > # add directory to library search path
> > > if [ -z "$LD_LIBRARY_PATH" ] ; then
> > >     LD_LIBRARY_PATH="/directory/where/lib/is/"
> > > else
> > >     LD_LIBRARY_PATH="/directory/where/lib/is/:${LD_LIBRARY_PATH}"
> > > fi
> > >
> > > # this should be unnecessary, don't have time to read the man-page
> > > export LD_LIBRARY_PATH
> > 
> > This assumes bash, doesnt it?
> 
> Well, it assumes a shell called '/bin/sh' - which on all existing UNIX/Linux
> varients is a 'Bourne-Shell' - or a close clone such as BASH. That's
> what the '#! /bin/sh' line at the top of the script does.

I am aware of the meaning of #!/bin/sh
What I meant was; doesn't the script _assume_ that /bin/sh is bash, by
using the keyword "export"? (Or is it Posix shell also?).

In case the script assumes sh is bash, you could rewrite the entire script
as

#!/bin/bash
LD_LIBRARY_PATH=/directory/where/lib/is/:$LD_LIBRARY_PATH /path/to/bin

which you could also just type on the command line. (Note, it it all on
the same line - it makes a difference).

> 
> Exporting LD_LIBRARY_PATH is certainly recommended.

I would argue against. You do not want to change the LD_LIBRARY_PATH for
your current shell, only either the subshell or command you run.

Changing LD_LIBRARY_PATH for your current shell can be a _bad_ idea.

btw: If it is a setuid root game, it wont use LD_LIBRARY_PATH anyway,
IIRC.

Mads

-- 
Mads Bondo Dydensborg.                               madsdyd@challenge.dk
Faced with the prospect of rereading this book, I would rather have my brains
ripped out by a plastic fork
                 - Charles Cooper, ZD net, in review of B@TSOT by Bill Gates.