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 [email protected] +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
