From ed6d3933070f7cfbb0607aabe8f9e71ca384791a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 4 Sep 2019 21:35:24 -0400 Subject: color: Actually resolve symlinks against their parent directory --- color.c | 2 +- tests.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/color.c b/color.c index aecee74..1c06d68 100644 --- a/color.c +++ b/color.c @@ -734,7 +734,7 @@ static ssize_t first_broken_offset(const char *path, const struct BFTW *ftwbuf, } } else { // We're in print_link_target(), so resolve relative to the link's parent directory - at_fd = AT_FDCWD; + at_fd = ftwbuf->at_fd; if (at_fd == AT_FDCWD && path[0] != '/') { at_path = dstrndup(ftwbuf->path, ftwbuf->nameoff); if (at_path && dstrncat(&at_path, path, max) != 0) { diff --git a/tests.sh b/tests.sh index b970547..b95be8b 100755 --- a/tests.sh +++ b/tests.sh @@ -2114,6 +2114,7 @@ function test_color_ls() { ln -s foo/bar/nowhere/nothing scratch/nested ln -s foo/bar/baz/qux scratch/notdir ln -s scratch/foo/bar scratch/relative + mkdir scratch/__bfs__ ln -s /__bfs__/nowhere scratch/absolute local EXPECTED="$TESTS/${FUNCNAME[0]}.out" -- cgit v1.2.3