mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Removal of current dir can be a pain without force
This commit is contained in:
parent
8a7d2bd1ed
commit
9272c90f93
13
src/nnn.c
13
src/nnn.c
|
@ -619,12 +619,14 @@ static void xdelay(void)
|
||||||
usleep(350000); /* 350 ms delay */
|
usleep(350000); /* 350 ms delay */
|
||||||
}
|
}
|
||||||
|
|
||||||
static char confirm_force(void)
|
static char confirm_force(bool selection)
|
||||||
{
|
{
|
||||||
char str[64] = {0};
|
char str[64] = "forcibly remove current file (UNRECOVERABLE)? [y/Y confirms]";
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
snprintf(str, 64, "forcibly remove %d files (UNRECOVERABLE)? [y/Y confirms]", nselected);
|
if (selection)
|
||||||
|
snprintf(str, 64, "forcibly remove %d file(s) (UNRECOVERABLE)? [y/Y confirms]", nselected);
|
||||||
|
|
||||||
r = get_input(str);
|
r = get_input(str);
|
||||||
|
|
||||||
if (r == 'y' || r == 'Y')
|
if (r == 'y' || r == 'Y')
|
||||||
|
@ -1293,9 +1295,9 @@ static void rmmulstr(char *buf)
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, CMD_LEN_MAX,
|
snprintf(buf, CMD_LEN_MAX,
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
"xargs -0 -a %s rm -%cr", g_selpath, confirm_force());
|
"xargs -0 -a %s rm -%cr", g_selpath, confirm_force(TRUE));
|
||||||
#else
|
#else
|
||||||
"cat %s | xargs -0 -o rm -%cr", g_selpath, confirm_force());
|
"cat %s | xargs -0 -o rm -%cr", g_selpath, confirm_force(TRUE));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1307,6 +1309,7 @@ static void xrm(char *path)
|
||||||
else {
|
else {
|
||||||
char rm_opts[] = "-ir";
|
char rm_opts[] = "-ir";
|
||||||
|
|
||||||
|
rm_opts[1] = confirm_force(FALSE);
|
||||||
spawn("rm", rm_opts, path, NULL, F_NORMAL);
|
spawn("rm", rm_opts, path, NULL, F_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue