.Pp
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact
.It Ic ^O
-Open with an application
+Open with an application (takes 1 combined argument)
.It Ic n
Create a new file or directory
.It Ic D
.Pp
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact
.It Ic o
-Launch a GUI application
+Launch a GUI application (takes 2 combined arguments)
.It Ic \&!, ^]
Spawn SHELL in current directory (fallback sh)
.It Ic R
*/
static void spawn(const char *file, const char *arg1, const char *arg2, const char *dir, uchar flag)
{
- static char *shlvl;
+ static const char *shlvl;
static pid_t pid;
static int status;
+ /* Swap args if the first arg is NULL and second isn't */
+ if (!arg1 && arg2) {
+ shlvl = arg1;
+ arg1 = arg2;
+ arg2 = shlvl;
+ }
+
if (flag & F_NORMAL)
exitcurses();
if (cfg.useeditor &&
get_output(g_buf, CMD_LEN_MAX, "file", FILE_OPTS, newpath, FALSE) &&
strstr(g_buf, "text/") == g_buf) {
- spawn(editor, newpath, editor_arg, path, F_NORMAL);
+ spawn(editor, editor_arg, newpath, path, F_NORMAL);
continue;
}
break; // fallthrough
case SEL_LAUNCH: // fallthrough
case SEL_NEW:
+ {
+ char *ptr = NULL, *ptr1 = NULL, *ptr2 = NULL;
+
if (sel == SEL_OPEN)
tmp = xreadline(NULL, "open with: ");
else if (sel == SEL_LAUNCH)
else
r = F_NOWAIT | F_NOTRACE;
+ getprogarg(tmp, &ptr);
mkpath(path, dents[cur].name, newpath, PATH_MAX);
- spawn(tmp, newpath, NULL, path, r);
+ spawn(tmp, ptr, newpath, path, r);
continue;
}
if (sel == SEL_LAUNCH) {
uint args = 0;
- char *ptr = tmp, *ptr1 = NULL, *ptr2 = NULL;
+ ptr = tmp;
while (*ptr) {
- if (*ptr == ' ') {
+ if (isblank(*ptr)) {
*ptr = '\0';
if (args == 0)
ptr1 = ptr + 1;
close(fd);
xstrlcpy(lastname, tmp, NAME_MAX + 1);
goto begin;
+ }
case SEL_RENAME:
if (!ndents)
break;
/* Repopulate as directory content may have changed */
goto begin;
case SEL_RUNEDIT:
- spawn(editor, dents[cur].name, editor_arg, path, F_NORMAL);
+ spawn(editor, editor_arg, dents[cur].name, path, F_NORMAL);
break;
case SEL_RUNPAGE:
- spawn(pager, dents[cur].name, pager_arg, path, F_NORMAL);
+ spawn(pager, pager_arg, dents[cur].name, path, F_NORMAL);
break;
case SEL_LOCK:
spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL | F_SIGINT);