diff options
author | Leah Neukirchen <leah@vuxu.org> | 2021-06-25 12:36:01 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2021-06-25 12:36:01 +0200 |
commit | ca309754c6aba81be4f290279666a68f75306d70 (patch) | |
tree | b28dffaef264c94e4e65f5f955daca0860e55596 | |
parent | c3f0e7052453fed04a696535145d40dfd2a3b6a3 (diff) | |
download | lr-ca309754c6aba81be4f290279666a68f75306d70.tar.gz lr-ca309754c6aba81be4f290279666a68f75306d70.tar.xz lr-ca309754c6aba81be4f290279666a68f75306d70.zip |
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.
-rw-r--r-- | lr.c | 3 |
1 files changed, 2 insertions, 1 deletions
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 */ |