From 11af4b31b61302188a65e521921c42ddb45c4fb9 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Wed, 25 Jan 2012 16:42:42 +0000 Subject: realpath: remove extraneous '/' for --relative-to edge cases * src/realpath.c (path_common_prefix): Be consistent and always include a leading '/' in the count returned. (relpath): Account for the change in path_common_prefix() and avoid outputting extra '/' chars in relative paths that span the root dir. * tests/misc/realpath: Add the two reported cases. Reported by Mike Frysinger --- tests/misc/realpath | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/misc') diff --git a/tests/misc/realpath b/tests/misc/realpath index fb0139367..8a1f336cd 100755 --- a/tests/misc/realpath +++ b/tests/misc/realpath @@ -41,13 +41,18 @@ realpath -m '' && fail=1 # symlink resolution this=$(realpath .) -test "$(realpath $relative ldir2/..)" = "$this/dir1" || fail=1 -test "$(realpath -L $relative ldir2/..)" = "$this" || fail=1 -test "$(realpath -s $relative ldir2)" = "$this/ldir2" || fail=1 +test "$(realpath ldir2/..)" = "$this/dir1" || fail=1 +test "$(realpath -L ldir2/..)" = "$this" || fail=1 +test "$(realpath -s ldir2)" = "$this/ldir2" || fail=1 # relative string handling test $(realpath -m --relative-to=prefix prefixed/1) = '../prefixed/1' || fail=1 test $(realpath -m --relative-to=prefixed prefix/1) = '../prefix/1' || fail=1 test $(realpath -m --relative-to=prefixed prefixed/1) = '1' || fail=1 +# Ensure no redundant trailing '/' present, as was the case in v8.15 +test $(realpath -sm --relative-to=/usr /) = '..' || fail=1 +# Ensure no redundant leading '../' present, as was the case in v8.15 +test $(realpath -sm --relative-to=/ /usr) = 'usr' || fail=1 + Exit $fail -- cgit v1.2.3-70-g09d2