Fix broken GUI cmd run as plugin case

This commit is contained in:
Arun Prakash Jana 2021-09-25 23:54:12 +05:30
parent f3e0f23718
commit 046d676a73
3 changed files with 14 additions and 5 deletions

1
nnn.1
View File

@ -401,6 +401,7 @@ separated by \fI;\fR:
export NNN_PLUG='y:-!sync*'
5. To run a \fIGUI app as plugin\fR, add a \fB&\fR after \fB!\fR
Note: $nnn must be the last argument in this case.
export NNN_PLUG='m:-!&mousepad $nnn'

View File

@ -165,6 +165,8 @@ To run a GUI app as plugin, add a `&` after `!`.
export NNN_PLUG='m:-!&mousepad $nnn'
```
Note: $nnn must be the last argument in this case.
#### Page non-interactive command output
To show the output of run-and-exit commands which do not need user input, add `|` (pipe) after `!`.

View File

@ -5108,7 +5108,7 @@ static void setexports(void)
}
}
static bool run_cmd_as_plugin(const char *file, uchar_t flags)
static bool run_cmd_as_plugin(const char *file, char *runfile, uchar_t flags)
{
size_t len;
@ -5122,8 +5122,14 @@ static bool run_cmd_as_plugin(const char *file, uchar_t flags)
}
if (flags & F_PAGE)
get_output(utils[UTIL_SH_EXEC], g_buf, NULL, -1, TRUE, TRUE);
else
get_output(g_buf, NULL, NULL, -1, TRUE, TRUE);
else if (flags & F_NOTRACE) {
if (is_suffix(g_buf, " $nnn"))
g_buf[len - 5] = '\0';
else
runfile = NULL;
spawn(g_buf, runfile, NULL, NULL, flags);
} else
spawn(utils[UTIL_SH_EXEC], g_buf, NULL, NULL, flags);
return TRUE;
@ -5257,7 +5263,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, flags);
return run_cmd_as_plugin(file, runfile, flags);
cmd_as_plugin = TRUE;
}
@ -5291,7 +5297,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, flags);
run_cmd_as_plugin(file, NULL, flags);
close(wfd);
_exit(EXIT_SUCCESS);