[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PATCH: relpath
From: |
Jim Meyering |
Subject: |
Re: PATCH: relpath |
Date: |
Sat, 31 Dec 2011 10:43:29 +0100 |
Pádraig Brady wrote:
> On 12/12/2011 12:24 AM, Pádraig Brady wrote:
>> FYI I'm not forgetting about this.
>> This week I'll be travelling with work,
>> but I intend to tackle this early the following week.
>
> Sorry for the delay.
> Attached is the realpath implementation, which I think
> turned into a good cohesive set of functionality.
> It has this interface:
Thanks!
I noticed a couple nits.
> Usage: src/realpath [OPTION] FILE...
> Print the resolved absolute file name;
> all but the last component must exist
>
> -e, --canonicalize-existing all components of the path must exist
> -m, --canonicalize-missing no components of the path need exist
> -L, --logical resolve `..' components before symlinks
> -P, --physical resolve symlinks as encountered (default)
> -q, --quiet suppress most error messages
> --relative-to=FILE print the resolved path relative to FILE
> --relative-base=FILE print absolute paths unless paths below FILE
> -s, --strip don't expand symlinks
> -z, --zero separate output with NUL rather than newline
>
> --help display this help and exit
> --version output version information and exit
>
> I was going to add a --readlink option to call readlink(3),
> but that's a separate function really, and since readlink(1)
> is widely available, I thought it better to not duplicate?
>
> I was going to add a --common-prefix mode, to print
> the common prefix of all supplied paths.
> We can do this in future anyway.
>
> Note this patch required this small update to gnulib:
> http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commit;h=8bcd0399
...
> Subject: [PATCH] readlink: A new program to print the resolved path
s/readlink: A/realpath: a/
> This program is compatible with other realpath(1)
> implementations, and also incorporates relpath like support,
> through the --relative options. The relpath support
> was suggested by Peng Yu, who also provided an initial
> implemenation of that functionality.
>
> * AUTHORS: Add my name.
> * NEWS: Mention the new command.
> * README: Likewise.
> * doc/coreutils.texi (realpath invocation): Add realpath info.
> * man/Makefile.am (realpath.1): Add dependency.
> * man/realpath.x: New template.
> * man/.gitignore: Ignore generated man page.
> * po/POTFILES.in: Add src/realpath.c.
> * src/.gitignore: Exclude realpath.
> * src/Makefile.am (EXTRA_PROGRAMS): Add realpath.
> * src/realpath.c: New file.
> * scripts/git-hooks/commit-msg: Add realpath to the list of prefixes.
> * tests/Makefile.am (TESTS): Add misc/realpath.
> * tests/misc/realpath: New file.
"make check" failed with this:
FAIL: misc/help-version (exit: 1)
=================================
...
+ args=
+ env realpath
realpath: missing operand
Try `realpath --help' for more information.
+ echo FAIL: realpath
FAIL: realpath
+ fail=1
The trivial patch is to tell this driver how to invoke the new program:
diff --git a/tests/misc/help-version b/tests/misc/help-version
index 0482209..ddb5b52 100755
--- a/tests/misc/help-version
+++ b/tests/misc/help-version
@@ -177,6 +177,7 @@ ln_setup () { args="$tmp_in ln-target"; }
ginstall_setup () { args="$tmp_in $tmp_in2"; }
mv_setup () { args="$tmp_in $tmp_in2"; }
mkdir_setup () { args=$tmp_dir/subdir; }
+realpath_setup () { args=$tmp_in; }
rmdir_setup () { args=$tmp_dir; }
rm_setup () { args=$tmp_in; }
shred_setup () { args=$tmp_in; }
-------------------------------------------------
Reading "info realpath", I saw this:
`-s'
`--strip'
Do not resolve symbolic links. Only resolve references to `/./',
`/../' and extra `/' characters.
How about inserting "remove"?
Do not resolve symbolic links. Only resolve references to `/./',
`/../' and remove extra `/' characters.
Also, if it's (as I assume) a text-only operation, never stat'ing
a named file, then say that:
Unlike other modes of operation, with this one, realpath operates
only on the file name, and does not touch any actual file.
-------------------------------------------------
Reading only the documentation for --relative-base=FILE,
I am not sure how it works:
`--relative-base=FILE'
Ensure both the `--relative-to' and processed files are
subdirectories of FILE, or otherwise output the absolute file name.
Note this option honors the `-m' and `-e' options pertaining to
file existence.
An example or two would help a lot.
I'll look through the rest later.
Re: PATCH: relpath, Jim Meyering, 2011/12/02
Re: PATCH: relpath, Pádraig Brady, 2011/12/05
- Re: PATCH: relpath, Pádraig Brady, 2011/12/05
- Re: PATCH: relpath, Pádraig Brady, 2011/12/11
- Re: PATCH: relpath, Pádraig Brady, 2011/12/30
- Re: PATCH: relpath,
Jim Meyering <=
- Re: PATCH: relpath, Pádraig Brady, 2011/12/31
- Re: PATCH: relpath, Jim Meyering, 2011/12/31
- Re: PATCH: relpath, Jim Meyering, 2011/12/31
Re: PATCH: relpath, Jim Meyering, 2011/12/31
Re: PATCH: relpath, Jim Meyering, 2011/12/31
RE: PATCH: relpath, Voelker, Bernhard, 2011/12/05