From fa7cef2df75c940994f4a700b317645034864b26 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 5 Sep 2021 18:19:30 +0530 Subject: [PATCH] The shell interprets "$nnn" now --- nnn.1 | 11 +++++------ plugins/README.md | 5 ++--- src/nnn.c | 15 +++++---------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/nnn.1 b/nnn.1 index eeb76b25..a172f39c 100644 --- a/nnn.1 +++ b/nnn.1 @@ -391,20 +391,19 @@ separated by \fI;\fR: NOTES: 1. Use single quotes for $NNN_PLUG so $nnn is not interpreted - 2. $nnn should be the last argument (IF used) - 3. (Again) add \fB!\fR before the command - 4. To disable directory refresh after running a \fIcommand as plugin\fR, + 2. (Again) add \fB!\fR before the command + 3. To disable directory refresh after running a \fIcommand as plugin\fR, prefix with \fB-!\fR - 5. To skip user confirmation after command execution, suffix with \fB*\fR + 4. To skip user confirmation after command execution, suffix with \fB*\fR Note: Do not use \fB*\fR with programs those run and exit e.g. cat export NNN_PLUG='y:-!sync*' - 6. To run a \fIGUI app as plugin\fR, add a \fB&\fR after \fB!\fR + 5. To run a \fIGUI app as plugin\fR, add a \fB&\fR after \fB!\fR export NNN_PLUG='m:-!&mousepad $nnn' - 7. To show the output of run-and-exit commands which do not need user input, + 6. To show the output of run-and-exit commands which do not need user input, add \fB|\fR (pipe) after \fB!\fR Note: This option is incompatible with \fB&\fR (terminal output is masked for GUI programs) and ignores \fB*\fR (output is already paged for user) diff --git a/plugins/README.md b/plugins/README.md index b2b43f6a..f1cb42ee 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -178,9 +178,8 @@ This option is incompatible with `&` (terminal output is masked for GUI programs Notes: 1. Use single quotes for `$NNN_PLUG` so `$nnn` is not interpreted -2. `$nnn` should be the last argument (IF used) -3. (_Again_) add `!` before the command -4. To disable directory refresh after running a _command as plugin_, prefix with `-!` +2. (_Again_) add `!` before the command +3. To disable directory refresh after running a _command as plugin_, prefix with `-!` #### Some useful key-command examples diff --git a/src/nnn.c b/src/nnn.c index 15d31dfb..167fdf3a 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -5076,7 +5076,7 @@ static void setexports(void) } } -static bool run_cmd_as_plugin(const char *file, char *runfile, uchar_t flags) +static bool run_cmd_as_plugin(const char *file, uchar_t flags) { size_t len; @@ -5089,15 +5089,10 @@ static bool run_cmd_as_plugin(const char *file, char *runfile, uchar_t flags) --len; } - if (is_suffix(g_buf, " $nnn")) - g_buf[len - 5] = '\0'; /* Set `\0` to clear ' $nnn' suffix */ - else - runfile = NULL; - if (flags & F_PAGE) - get_output(g_buf, runfile, NULL, -1, TRUE, TRUE); + get_output(g_buf, NULL, NULL, -1, TRUE, TRUE); else - spawn(g_buf, runfile, NULL, NULL, flags); + spawn(g_buf, NULL, NULL, NULL, flags); return TRUE; } @@ -5230,7 +5225,7 @@ static bool run_plugin(char **path, const char *file, char *runfile, char **last return FALSE; if ((flags & F_NOTRACE) || (flags & F_PAGE)) - return run_cmd_as_plugin(file, runfile, flags); + return run_cmd_as_plugin(file, flags); cmd_as_plugin = TRUE; } @@ -5264,7 +5259,7 @@ static bool run_plugin(char **path, const char *file, char *runfile, char **last } else spawn(g_buf, NULL, *path, sel, 0); } else - run_cmd_as_plugin(file, runfile, flags); + run_cmd_as_plugin(file, flags); close(wfd); _exit(EXIT_SUCCESS);