aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-11-17 17:45:22 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-11-17 17:45:22 +0530
commit407b690404e60f3c66a8b7bb2b580b8d2e6e61f3 (patch)
tree59a68c342bc52e4bb6138ba1ebbcba3c7a0951e7
parentf4acfc7a4e065bab2f4e01f1c641d0b398deb8d7 (diff)
downloadnnn-407b690404e60f3c66a8b7bb2b580b8d2e6e61f3.tar.gz
Fix #384: support busybox xargs
-rw-r--r--README.md2
-rw-r--r--src/nnn.c17
2 files changed, 7 insertions, 12 deletions
diff --git a/README.md b/README.md
index e968f4c..169056f 100644
--- a/README.md
+++ b/README.md
@@ -88,7 +88,7 @@ A curses library with wide char support (e.g. ncursesw), libreadline (`make O_NO
| Dependency | Installation | Operation |
| --- | --- | --- |
| xdg-open (Linux), open(1) (macOS), cygstart (Cygwin) | base | desktop opener |
-| file, coreutils (cp, mv, rm), findutils (xargs) | base | file type, copy, move and remove |
+| file, coreutils (cp, mv, rm), xargs | base | file type, copy, move and remove |
| tar, (un)zip [atool/bsdtar for more formats] | base | create, list, extract tar, gzip, bzip2, zip |
| archivemount, fusermount(3) | optional | mount, unmount archives |
| sshfs, fusermount(3) | optional | mount, unmount remotes |
diff --git a/src/nnn.c b/src/nnn.c
index b50f8d4..9f6cd9b 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1278,7 +1278,7 @@ static bool xdiraccess(const char *path)
static void opstr(char *buf, char *op)
{
#ifdef __linux__
- snprintf(buf, CMD_LEN_MAX, "xargs -0 -a %s -%c {} %s {} .", g_selpath, REPLACE_STR, op);
+ snprintf(buf, CMD_LEN_MAX, "cat %s | xargs -0 -%c {} %s {} .", g_selpath, REPLACE_STR, op);
#else
snprintf(buf, CMD_LEN_MAX, "cat %s | xargs -0 -o -%c {} %s {} .", g_selpath, REPLACE_STR, op);
#endif
@@ -1286,17 +1286,12 @@ static void opstr(char *buf, char *op)
static void rmmulstr(char *buf)
{
- if (cfg.trash) {
- snprintf(buf, CMD_LEN_MAX,
-#ifdef __linux__
- "xargs -0 -a %s trash-put", g_selpath);
-#else
- "cat %s | xargs -0 trash-put", g_selpath);
-#endif
- } else {
+ if (cfg.trash)
+ snprintf(buf, CMD_LEN_MAX, "cat %s | xargs -0 trash-put", g_selpath);
+ else {
snprintf(buf, CMD_LEN_MAX,
#ifdef __linux__
- "xargs -0 -a %s rm -%cr", g_selpath, confirm_force(TRUE));
+ "cat %s | xargs -0 rm -%cr", g_selpath, confirm_force(TRUE));
#else
"cat %s | xargs -0 -o rm -%cr", g_selpath, confirm_force(TRUE));
#endif
@@ -1335,7 +1330,7 @@ static bool cpmv_rename(int choice, const char *path)
bool ret = FALSE;
char *cmd = (choice == 'c' ? cp : mv);
static const char formatcmd[] = "sed -i 's|^\\(\\(.*/\\)\\(.*\\)$\\)|#\\1\\n\\3|' %s";
- static const char renamecmd[] = "sed 's|^\\([^#][^/]\\?.*\\)$|%s/\\1|;s|^#\\(/.*\\)$|\\1|' %s | tr '\\n' '\\0' | xargs -0 -o -n2 %s";
+ static const char renamecmd[] = "sed 's|^\\([^#][^/]\\?.*\\)$|%s/\\1|;s|^#\\(/.*\\)$|\\1|' %s | tr '\\n' '\\0' | xargs -0 -n2 %s";
char buf[sizeof(renamecmd) + sizeof(cmd) + (PATH_MAX << 1)];
fd = create_tmp_file();