From ca309754c6aba81be4f290279666a68f75306d70 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 25 Jun 2021 12:36:01 +0200 Subject: print_noprefix: only drop char after prefixl if it is a / Else the first character gets lost in this example: % mkdir -p service/src service/test % touch service/src/foo.c %lr -B -s service/src service/test . . oo.c Reported by @Profpatsch. --- lr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lr.c b/lr.c index 276abec..b523265 100644 --- a/lr.c +++ b/lr.c @@ -1782,7 +1782,8 @@ print_noprefix(struct fileinfo *fi) if (fi->prefixl == 0 && fi->fpath[0]) print_shquoted(fi->fpath); else if (strlen(fi->fpath) > fi->prefixl + 1) /* strip prefix */ - print_shquoted(fi->fpath + fi->prefixl + 1); + print_shquoted(fi->fpath + fi->prefixl + + (fi->fpath[fi->prefixl] == '/')); else if (S_ISDIR(fi->sb.st_mode)) /* turn empty string into "." */ printf("."); else /* turn empty string into basename */ -- cgit 1.4.1