From 9f5aa4850133976eee22dcc0b506d7b632cd674c Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 14 Mar 2012 13:42:59 -0600 Subject: realpath: let --relative-to default to --relative-base Most of the time, if someone wants to filter which paths are relative while leaving all others absolute, they also want to to the filtering based on the same --relative-to directory. Make this easier to specify. * src/realpath.c (main): Convert error to default. * doc/coreutils.texi (realpath invocation): Document this. * tests/misc/realpath: Adjust test to match. * NEWS: Document it. --- tests/misc/realpath | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/misc/realpath b/tests/misc/realpath index 1b83a0496..9484ac4c8 100755 --- a/tests/misc/realpath +++ b/tests/misc/realpath @@ -43,11 +43,8 @@ ln -s /// three || framework_failure_ realpath -Pqz . >/dev/null || fail=1 # Operand is required realpath >/dev/null && fail=1 -# --relative-base and --relative-to require params realpath --relative-base . --relative-to . && fail=1 -# --relative-base requires --relative-to -realpath --relative-base=dir1 . && fail=1 -realpath --relative-base --relative-to=dir1 . && fail=1 +realpath --relative-base . && fail=1 # -e --relative-* require directories realpath -e --relative-to=dir1/f --relative-base=. . && fail=1 @@ -78,6 +75,11 @@ out=$(realpath -sm --relative-base=/usr --relative-to=/usr /tmp /usr) || fail=1 test "$out" = "/tmp$nl." || fail=1 out=$(realpath -sm --relative-base=/ --relative-to=/ / /usr) || fail=1 test "$out" = ".${nl}usr" || fail=1 +# --relative-to defaults to the value of --relative-base +out=$(realpath -sm --relative-base=/usr /tmp /usr) || fail=1 +test "$out" = "/tmp$nl." || fail=1 +out=$(realpath -sm --relative-base=/ / /usr) || fail=1 +test "$out" = ".${nl}usr" || fail=1 # For now, --relative-base must be a prefix of --relative-to, or all output # will be absolute (compare to MacOS 'relpath -d dir start end'). out=$(realpath -sm --relative-base=/usr/local --relative-to=/usr \ -- cgit v1.2.3-54-g00ecf