This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
Re: base-files: Does not permit the use of symlinks in /etc/profile.d/
On Sun, September 18, 2005 1:14 am, Max Bowsher wrote:
> Eric Blake wrote:
>>>> 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.
>
> This makes me think: Why are we trying so incredibly hard to detect
> directories?
Humm, hold over from the first days of this code I would imagine.
> If someone does someone so incredibly bizarre as creating a directory
> named
> '/etc/profile.d/foobar.sh/' (or .zsh or .csh), why not let them suffer the
> error message?
Not a problem really, so, do I go with:
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
do we even need the outer if?
J.