summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-08-29 17:06:44 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-08-29 17:07:30 +0200
commit94c3fded196b94eede0cb9fd685f9211d15f70ae (patch)
treed8b5cc97d8ff4172f6c6ce36e87ecfc6e8760193
parent868aef09596db3ee7dc17519342550329f52ae29 (diff)
downloadlr-94c3fded196b94eede0cb9fd685f9211d15f70ae.tar.gz
lr-94c3fded196b94eede0cb9fd685f9211d15f70ae.tar.xz
lr-94c3fded196b94eede0cb9fd685f9211d15f70ae.zip
recurse: need special case for "lr /"
-rw-r--r--lr.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lr.c b/lr.c
index 229591a..2c79425 100644
--- a/lr.c
+++ b/lr.c
@@ -1814,6 +1814,7 @@ recurse(char *path, struct history *h)
 	const char *fpath = *path ? path : ".";
 
 	int resolve = Lflag || (Hflag && !h);
+	int root = (path[0] == '/' && path[1] == 0);
 
 	if (resolve ? stat(fpath, &st) : lstat(fpath, &st) < 0) {
 		if (resolve && errno == ENOENT && !lstat(fpath, &st)) {
@@ -1870,7 +1871,7 @@ recurse(char *path, struct history *h)
 					closedir(d);
 					return -1;
 				}
-				if (j > 0) {
+				if (j > 0 || root) {
 					path[j] = '/';
 					strcpy(path + j + 1, de->d_name);
 				} else {