commit 046d676a73b70d5c8bd39a5a37866aa75fe70598
parent f3e0f2371825f845d50fe0107acca637cbd165aa
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Sat, 25 Sep 2021 23:54:12 +0530
Fix broken GUI cmd run as plugin case
Diffstat:
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/nnn.1 b/nnn.1
@@ -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'
diff --git a/plugins/README.md b/plugins/README.md
@@ -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 `!`.
diff --git a/src/nnn.c b/src/nnn.c
@@ -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);