This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: base-files: Does not permit the use of symlinks in /etc/profile.d/


> > Sorry, didn't realise.  If I change the line
> >
> > /bin/find /etc/profile.d -type f -iname '*.sh' -or -iname '*.zsh'
> >
> > to be
> >
> > /bin/find -L /etc/profile.d -type f -iname '*.sh' -or -iname '*.zsh'
> >
> > would that fix things?  (The -L tells find to follow the link and make
> > decisions based on the actual file AFAICT).
> 
> Would find then apply the -iname tests to the link destination too, then? 

True - once you turn on -L, all the tests are applied to the destination.
Also, the existing code is redundant (find has already proven the
file exists and is regular, so the [ -f "${f}" ] is unneeded), and buggy,
since it tries to source non-files named *.zsh, as though it were written:
\( -type f -a -iname '*.sh' \) -o -iname '*.zsh'

So how about this:

if [ -d "/etc/profile.d" ]; then
        for f in `/bin/find /etc/profile.d -xtype f  \( -iname '*.sh' -o -iname '*.zsh' \) | LC_ALL=C sort`
        do
                . "$f"
        done
fi

> That would be a potential confusion. How about using \( -type f -o -type l 
> \) ?

-type l won't cut it, because it gets false positives on a symlink to a directory.

--
Eric Blake



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]