GNU bug report logs -
#10472
`realpath --relative-to=<path> /` outputs inconsistent trailing slash
Previous Next
Reported by: Mike Frysinger <vapier <at> gentoo.org>
Date: Tue, 10 Jan 2012 20:17:02 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#10472: `realpath --relative-to=<path> /` outputs inconsistent trailing slash
which was filed against the coreutils package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 10472 <at> debbugs.gnu.org.
--
10472: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10472
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
On 01/10/2012 10:30 PM, Pádraig Brady wrote:
> On 01/10/2012 09:53 PM, Mike Frysinger wrote:
>> On Tuesday 10 January 2012 15:15:57 Mike Frysinger wrote:
>>> as does these:
>>> realpath --relative-to=/ /usr
>>> realpath --relative-to=/ /usr/
>>> which is to say, they show:
>>> ..
>>
>> sorry, typo here ... these actually output:
>> ../usr
>>
>> i guess that should be just "usr".
>> -mike
>
> Agreed. python concurs too:
>
>>>> os.path.relpath(start='/usr',path='/')
> '..'
>>>> os.path.relpath(start='/',path='/usr')
> 'usr'
>
> Essentially in these edge cases the relative paths
> printed are valid, but not canonicalised.
>
> I'll fix it up.
Proposed fix attached.
cheers,
Pádraig.
[relpath-edge-cases.diff (text/plain, attachment)]
[Message part 5 (message/rfc822, inline)]
[Message part 6 (text/plain, inline)]
first some examples that look fine ...
these all output the same thing:
realpath --relative-to=/usr /usr/bin
realpath --relative-to=/usr/ /usr/bin
realpath --relative-to=/usr /usr/bin/
realpath --relative-to=/usr/ /usr/bin/
which is to say, they show:
bin
as does these:
realpath --relative-to=/usr/bin /usr
realpath --relative-to=/usr/bin/ /usr
realpath --relative-to=/usr/bin /usr/
realpath --relative-to=/usr/bin/ /usr/
which is to say, they show:
..
as does these:
realpath --relative-to=/ /usr
realpath --relative-to=/ /usr/
which is to say, they show:
..
however, if the last argument is just the root path:
realpath --relative-to=/usr /
realpath --relative-to=/usr/ /
we end up with a trailing slash:
../
for consistency, i don't think that should be the case
(reported by Ulrich Müller via https://bugs.gentoo.org/398339)
-mike
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 13 years and 75 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.