[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/6] realpath: let --relative-base work even as child of --re
From: |
Eric Blake |
Subject: |
Re: [PATCH 6/6] realpath: let --relative-base work even as child of --relative-to |
Date: |
Thu, 15 Mar 2012 13:38:36 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 |
On 03/14/2012 02:38 PM, Eric Blake wrote:
> Consider: 'realpath --relative-base=$dir --relative-to=. $file'
> It seems reasonable to get a relative name to $file if file is under
> $dir, without regards to where '.' lives, but prior to this patch,
> if '.' is a parent of $dir, the output was absolute.
>
> * src/realpath.c (relpath): Relax filtering of base.
> * doc/coreutils.texi (realpath invocation): Document this.
> * tests/misc/realpath (out): Adjust test to match.
> * NEWS: Document this.
> ---
> NEWS | 4 +++-
> doc/coreutils.texi | 6 +++---
> src/realpath.c | 8 ++------
> tests/misc/realpath | 5 ++---
> 4 files changed, 10 insertions(+), 13 deletions(-)
Based on what I've pushed, the changes to realpath.c (if we decide to
take this patch) are now:
diff --git i/src/realpath.c w/src/realpath.c
index 206f800..a1453b0 100644
--- i/src/realpath.c
+++ w/src/realpath.c
@@ -341,21 +341,11 @@ main (int argc, char **argv)
can_relative_base = can_relative_to;
else if (relative_base)
{
- char *base = realpath_canon (relative_base, can_mode);
- if (!base)
+ can_relative_base = realpath_canon (relative_base, can_mode);
+ if (!can_relative_base)
error (EXIT_FAILURE, errno, "%s", quote (relative_base));
- if (need_dir && !isdir (base))
+ if (need_dir && !isdir (can_relative_base))
error (EXIT_FAILURE, ENOTDIR, "%s", quote (relative_base));
- /* --relative-to is a no-op if it does not have --relative-base
- as a prefix */
- if (path_prefix (base, can_relative_to))
- can_relative_base = base;
- else
- {
- free (base);
- can_relative_base = can_relative_to;
- can_relative_to = NULL;
- }
}
for (; optind < argc; ++optind)
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [PATCH 0/6] realpath cleanups, Eric Blake, 2012/03/14
- [PATCH 5/6] doc: clarify current realpath --relative-base behavior, Eric Blake, 2012/03/14
- [PATCH 2/6] realpath: fix problems with root handling, Eric Blake, 2012/03/14
- [PATCH 6/6] realpath: let --relative-base work even as child of --relative-to, Eric Blake, 2012/03/14
- Re: [PATCH 6/6] realpath: let --relative-base work even as child of --relative-to,
Eric Blake <=
- [PATCH 1/6] test: expose recent gnulib canonicalize bug, Eric Blake, 2012/03/14
- [PATCH 4/6] realpath: let --relative-to default to --relative-base, Eric Blake, 2012/03/14
- [PATCH 3/6] tests: cover more realpath scenarios, Eric Blake, 2012/03/14
- Re: [PATCH 0/6] realpath cleanups, Pádraig Brady, 2012/03/14