aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar KlZX <azszwymmvqdi@yahoo.com>2019-08-12 11:36:09 +0200
committerGravatar KlZX <azszwymmvqdi@yahoo.com>2019-08-12 11:36:09 +0200
commit4cedba3d4d483cc27dd39373f3cc4c4606b4b715 (patch)
tree70d0fd6bd4cc46ef67d11c030f9c4f5fa7cacec1
parent7eafce9b45cbf8c6609434c420b9f7fe8a962454 (diff)
downloadnnn-4cedba3d4d483cc27dd39373f3cc4c4606b4b715.tar.gz
Fix 'batch_rename' moving symlinks
-rw-r--r--src/nnn.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 9290d94..7f021cf 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1213,13 +1213,7 @@ static bool batch_rename(const char *path)
int fd1, fd2, i;
uint count = 0, lines = 0;
bool dir = FALSE, ret = FALSE;
- const char renamecmd[] =
-#ifdef __OpenBSD__
- /* OpenBSD does not have the -n option for mv */
- "paste -d'\n' %s %s | tr '\n' '\\0' | xargs -0 -n2 mv 2>/dev/null";
-#else
- "paste -d'\n' %s %s | tr '\n' '\\0' | xargs -0 -n2 mv -n 2>/dev/null";
-#endif
+ const char renamecmd[] = "awk 'FNR==NR{a[NR]=$0} a[FNR]!=$0{printf \"%%s\\0%%s\\0\",a[FNR],$0}' %s %s | xargs -0 -n2 mv 2>/dev/null";
char foriginal[TMP_LEN_MAX] = {0};
char buf[sizeof(renamecmd) + (PATH_MAX << 1)];