On Tue, 23 Feb 2010, Martin Costabel wrote:

> patrick.wamb...@esat.kuleuven.be wrote:
> []
>> I don't see why /sw/bin/init.sh would clean up all this: as far as
>> I can see it only prepends /sw/bin:/sw/sbin to the PATH if that string is 
>> not already present (at least in my version of the script, which was 
>> installed along with fink and never modified by me).
>
> I see. I am a tcsh user myself, so I am familiar with its behavior. For bash 
> I have to make experiments. The latest experiment shows:
>
> For tcsh, the script /sw/bin/init.csh always prepends the fink paths to PATH. 
> If they are already present in $PATH, they are removed first. This is the 
> behavior I would call "cleaning up the mess".
>
> For bash, the script /sw/bin/init.sh only prepends the fink paths to PATH if 
> they are not already present in $PATH. If they are present, it does nothing. 
> I don't know if this is done by purpose or by laziness.
>
> I am too tired now to try to understand the difference between
>
> if ( $\!:1 !~ \!:2\:* && $\!:1 !~ *\:\!:2\:* && $\!:1 !~ *\:\!:2 && $\!:1 !~ 
> \!:2 ) setenv \!:1 \!:2\:${\!:1}; if ( $\!:1 !~ \!:2\:* ) setenv \!:1 
> \!:2`echo \:${\!:1} | /usr/bin/sed -e s%^\!:2\:%% -e s%:\!:2\:%:%g -e 
> s%:\!:2\$%%`
>
> and
>
>  if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o -z 
> "\"\${$1##$2:*}\"" -o -z "\"\${$1##$2}\"" ; then
>    eval "$1=$2:\$$1"
>  fi

This is what happens according to me (I could be wrong - I am not a 
specialist in shell programming):

in the first case (csh): if PATH (the first argument) does not contain 
/sw/bin:/sw/sbin (the second argument) either in the front, in the 
middle, at the end or both are exactly equal, in summary it contains 
nothing of the kind /sw/bin:/sw/sbin anywhere, then /sw/bin:/sw/sbin 
is prepended (first setenv). Then comes the second test: if PATH does 
not contain /sw/bin:/sw/sbin in the front (but maybe in another 
position), then it is prepended again and every other instance is 
removed (`echo etc` removes all instances).

in the second case (sh): if PATH (the first argument) does not contain 
/sw/bin:/sw/sbin (the second argument) either in the middle, at the 
end, in the front or both are exactly equal, in summary it contains 
nothing of the kind /sw/bin:/sw/sbin anywhere, then /sw/bin:/sw/sbin 
is prepended. That's all. That means that if /sw/bin:/sw/sbin was 
already there, then nothing is changed and the PATH remains wrong if 
it was there in another position than at the front.

I could try to remedy the second case to make it work like the first 
one, but I need to experiment with it since I am not at all a good 
shell programmer. Maybe there is a reason for this difference?

Patrick

>
> In any case, this code hasn't changed in 6 years.
>
> -- 
> Martin
>

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Fink-users mailing list
Fink-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-users

Reply via email to