coreutils
[Top][All Lists]
Advanced

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

Re: realpath options


From: Pádraig Brady
Subject: Re: realpath options
Date: Mon, 02 Jan 2012 22:08:46 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 01/02/2012 08:06 PM, Bruno Haible wrote:
> Pádraig Brady wrote in
> <http://lists.gnu.org/archive/html/bug-gnulib/2011-12/msg00237.html>:
>> This is for use in a proposed coreutils `realpath` command.
>> Specifically by these options:
>>
>>   -L, --logical                resolve `..' components before symlinks
>>   -s, --strip                  don't expand symlinks
> 
> The names of these options don't feel right.

I agree with you neither case is ideal, but...

> 
>   * --strip means making something shorter, but the resulting file name
>     is not necessarily shorter: After "ln -s . dot",
>     "realpath dot/dot/foo" will be "/currdir/foo",
>     "realpath -s dot/dot/foo" will be "/currdir/dot/dot/foo".

>     How about calling this option 'no-dereference', similar to the
>     option of 'chown', 'chgrp', 'chcon', 'cp', 'touch'?

--strip was used to be compatible with the util already in Debian.
It's not to bad really, as it doesn't mention symlinks directly,
as they're secondary to the operation.

I considered using --no-dereference, but while the symlinks
in a path are not expanded, they are dereferenced unless -m is specified.
Also --no-deref is used with and without -P in other coreutils,
and I wanted to use -P also for the reason described below:

$ grep -F -- no\\-deref man/*.1
man/chcon.1:\fB\-h\fR, \fB\-\-no\-dereference\fR
man/chgrp.1:\fB\-h\fR, \fB\-\-no\-dereference\fR
man/chown.1:\fB\-h\fR, \fB\-\-no\-dereference\fR
man/cp.1:\fB\-P\fR, \fB\-\-no\-dereference\fR
man/du.1:\fB\-P\fR, \fB\-\-no\-dereference\fR
man/ln.1:\fB\-n\fR, \fB\-\-no\-dereference\fR
man/touch.1:\fB\-h\fR, \fB\-\-no\-dereference\fR

$ grep -F -- \\-P man/*.1 | grep -v deref
man/chcon.1:\fB\-P\fR
man/chgrp.1:\fB\-P\fR
man/chown.1:\fB\-P\fR
man/ln.1:\fB\-P\fR, \fB\-\-physical\fR
man/pwd.1:\fB\-P\fR, \fB\-\-physical\fR

>     Or '--ignore-symlinks'?
> 
>   * --logical is meant to be the opposite of "physical", right?
>     How about calling this option --syntactic? Would be more self-
>     explanatory.

To me realpath is conceptually (cd; pwd), so I used
the -L and -P options as defined by POSIX for cd.
Quoting the spec for cd:

"
−L Handle the operand dot-dot logically; symbolic link components shall not be
    resolved before dot-dot components are processed (see steps 8. and 9. in the
   DESCRIPTION).
−P Handle the operand dot-dot physically; symbolic link components shall be
    resolved before dot-dot components are processed (see step 7. in the
   DESCRIPTION).
"

The above describe the operation (symlink resolution order) very concisely to 
me.

cheers,
Pádraig.

p.s. The bash docs for `cd -LP` were very confusing to me, so
I sent a patch along the lines of the above descriptions.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]