summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2012-01-25 16:42:42 +0000
committerPádraig Brady <P@draigBrady.com>2012-01-25 18:01:52 +0000
commit11af4b31b61302188a65e521921c42ddb45c4fb9 (patch)
tree8cab26a184bf4f9776b25b61f7bdd6292645cac1 /tests/misc
parente9a2555826767baae96a3eabca1f9d91bddca619 (diff)
downloadcoreutils-11af4b31b61302188a65e521921c42ddb45c4fb9.tar.xz
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
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/realpath11
1 files changed, 8 insertions, 3 deletions
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