mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Don't use xargs options -I -o and -a (#388)
Also removed another stray cat
This commit is contained in:
parent
cb3ee616c2
commit
4db8a61dea
33
src/nnn.c
33
src/nnn.c
|
@ -348,15 +348,6 @@ static char g_pipepath[TMP_LEN_MAX] __attribute__ ((aligned));
|
||||||
/* Plugin control initialization status */
|
/* Plugin control initialization status */
|
||||||
static bool g_plinit = FALSE;
|
static bool g_plinit = FALSE;
|
||||||
|
|
||||||
/* Replace-str for xargs on different platforms */
|
|
||||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
|
||||||
#define REPLACE_STR 'J'
|
|
||||||
#elif defined(__linux__) || defined(__CYGWIN__)
|
|
||||||
#define REPLACE_STR 'I'
|
|
||||||
#else
|
|
||||||
#define REPLACE_STR 'I'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Options to identify file mime */
|
/* Options to identify file mime */
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#define FILE_MIME_OPTS "-bIL"
|
#define FILE_MIME_OPTS "-bIL"
|
||||||
|
@ -1279,29 +1270,15 @@ static bool xdiraccess(const char *path)
|
||||||
|
|
||||||
static void opstr(char *buf, char *op)
|
static void opstr(char *buf, char *op)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
snprintf(buf, CMD_LEN_MAX, "xargs -0 sh -c '%s $0 $@ . < /dev/tty' < %s", op, g_selpath);
|
||||||
snprintf(buf, CMD_LEN_MAX, "xargs -0 -a %s -%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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmmulstr(char *buf)
|
static void rmmulstr(char *buf)
|
||||||
{
|
{
|
||||||
if (cfg.trash) {
|
if (cfg.trash) {
|
||||||
snprintf(buf, CMD_LEN_MAX,
|
snprintf(buf, CMD_LEN_MAX, "xargs -0 trash-put < %s", g_selpath);
|
||||||
#ifdef __linux__
|
|
||||||
"xargs -0 -a %s trash-put", g_selpath);
|
|
||||||
#else
|
|
||||||
"cat %s | xargs -0 trash-put", g_selpath);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, CMD_LEN_MAX,
|
snprintf(buf, CMD_LEN_MAX, "xargs -0 sh -c 'rm -%cr $0 $@ < /dev/tty' < %s", confirm_force(TRUE), g_selpath);
|
||||||
#ifdef __linux__
|
|
||||||
"xargs -0 -a %s rm -%cr", g_selpath, confirm_force(TRUE));
|
|
||||||
#else
|
|
||||||
"cat %s | xargs -0 -o rm -%cr", g_selpath, confirm_force(TRUE));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1337,7 +1314,7 @@ static bool cpmv_rename(int choice, const char *path)
|
||||||
bool ret = FALSE;
|
bool ret = FALSE;
|
||||||
char *cmd = (choice == 'c' ? cp : mv);
|
char *cmd = (choice == 'c' ? cp : mv);
|
||||||
static const char formatcmd[] = "sed -i 's|^\\(\\(.*/\\)\\(.*\\)$\\)|#\\1\\n\\3|' %s";
|
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 sh -c '%s $0 $@ < /dev/tty'";
|
||||||
char buf[sizeof(renamecmd) + sizeof(cmd) + (PATH_MAX << 1)];
|
char buf[sizeof(renamecmd) + sizeof(cmd) + (PATH_MAX << 1)];
|
||||||
|
|
||||||
fd = create_tmp_file();
|
fd = create_tmp_file();
|
||||||
|
@ -1530,7 +1507,7 @@ static void archive_selection(const char *cmd, const char *archive, const char *
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
"sed -ze 's|^%s/||' '%s' | xargs -0 %s %s", curpath, g_selpath, cmd, archive);
|
"sed -ze 's|^%s/||' '%s' | xargs -0 %s %s", curpath, g_selpath, cmd, archive);
|
||||||
#else
|
#else
|
||||||
"cat '%s' | tr '\\0' '\n' | sed -e 's|^%s/||' | tr '\n' '\\0' | xargs -0 %s %s",
|
"tr '\\0' '\n' < '%s' | sed -e 's|^%s/||' | tr '\n' '\\0' | xargs -0 %s %s",
|
||||||
g_selpath, curpath, cmd, archive);
|
g_selpath, curpath, cmd, archive);
|
||||||
#endif
|
#endif
|
||||||
spawn(utils[SH_EXEC], buf, NULL, curpath, F_CLI);
|
spawn(utils[SH_EXEC], buf, NULL, curpath, F_CLI);
|
||||||
|
|
Loading…
Reference in a new issue