aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-18 22:27:23 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-18 22:27:23 +0530
commitac281cb63b8c5dc8881a91303eab715b08c228bd (patch)
tree6de78c79edc3269b8b50bc577fe7cc2d2b1b2006
parent6b5bb16b46cbf8ee2b6c34d7b52ddbf872f40930 (diff)
downloadnnn-ac281cb63b8c5dc8881a91303eab715b08c228bd.tar.gz
Fix cmd as plugin showing prompt on playing twice
-rw-r--r--src/nnn.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 2781481..81fe06d 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3553,28 +3553,27 @@ static void show_help(const char *path)
unlink(g_tmpfpath);
}
-static bool run_cmd_as_plugin(const char *path, char *file, char *newpath, char *runfile)
+static bool run_cmd_as_plugin(const char *path, const char *file, char *newpath, char *runfile)
{
uchar flags = F_CLI | F_CONFIRM;
size_t len;
- DPRINTF_S(file);
-
/* Get rid of preceding _ */
++file;
if (!*file)
return FALSE;
- len = strlen(file);
- if (len > 1 && file[len - 1] == '*') {
+ xstrlcpy(newpath, file, PATH_MAX);
+
+ len = strlen(newpath);
+ if (len > 1 && newpath[len - 1] == '*') {
flags &= ~F_CONFIRM; /* GUI case */
- file[len - 1] = '\0'; /* Get rid of trailing nowait symbol */
+ newpath[len - 1] = '\0'; /* Get rid of trailing nowait symbol */
--len;
}
- xstrlcpy(newpath, file, PATH_MAX);
- if (is_suffix(file, " $nnn")) {
+ if (is_suffix(newpath, " $nnn")) {
/* Set `\0` to clear ' $nnn' suffix */
newpath[len - 5] = '\0';
} else
@@ -3599,7 +3598,7 @@ static bool plctrl_init(void)
return _SUCCESS;
}
-static bool run_selected_plugin(char **path, char *file, char *newpath, char *runfile, char **lastname, char **lastdir)
+static bool run_selected_plugin(char **path, const char *file, char *newpath, char *runfile, char **lastname, char **lastdir)
{
int fd;
size_t len;