Re: master 9d626df: Add 'nofollow' flag to set-file-modes etc.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: master 9d626df: Add 'nofollow' flag to set-file-modes etc.

Paul Eggert
On 2/24/20 5:52 AM, Michael Albinus wrote:

> However, for POSIX shells it is different. FreeBSD supports the "chmod
> -h" argument, which implements nofollow. See
> <https://www.freebsd.org/cgi/man.cgi?chmod>. I could check for this
> argument, and use if possible.
>
> But what shall I do if the target system runs GNU/Linux? chmod(1) does
> not offer any comparable argument. Shall I simply ignore nofollow there?

How about something like this?

if (chmod -h works); then
   chmod -h MODE FILE
elif (test -h works); then
   test -h FILE && chmod MODE FILE
else
   chmod MODE FILE
fi

I'm suggesting 'test -h' rather than 'test -L' here because some ancient
platforms support the former but not the latter.

> Does anybody know, whether there are plans to extend chmod accordingly,
> for example the version in coreutils? Or is there an alternative
> possiblity to change the permission of the symbolic link?

It should be added to the coreutils TODO list, if it's not there
already. On GNU/Linux symlink modes cannot be changed, for what it's
worth, so chmod -h would merely be a safety feature.