#define F_MULTI 0x01 /* first arg can be combination of args; to be used with F_NORMAL */
#define F_NOWAIT 0x02 /* don't wait for child process (e.g. file manager) */
#define F_NOTRACE 0x04 /* suppress stdout and strerr (no traces) */
-#define F_SIGINT 0x08 /* restore default SIGINT handler */
-#define F_EDIT 0x10 /* spawn the editor */
-#define F_NORMAL 0x20 /* spawn child process in non-curses regular CLI mode */
+#define F_NORMAL 0x08 /* spawn child process in non-curses regular CLI mode */
-#define F_PAGER (F_NORMAL | F_MULTI)
-#define F_SHELL (F_NORMAL | F_MULTI | F_SIGINT)
-#define F_EDITOR (F_NORMAL | F_MULTI | F_EDIT)
+#define F_CLI (F_NORMAL | F_MULTI)
/* CRC8 macros */
#define WIDTH (sizeof(unsigned char) << 3)
#endif
/* Common strings */
-#define STR_NFTWFAIL_ID 0
-#define STR_NOHOME_ID 1
-#define STR_INPUT_ID 2
-#define STR_INVBM_KEY 3
-#define STR_DATE_ID 4
-#define STR_UNSAFE 5
-#define STR_TMPFILE 6
-#define STR_ARGLIMIT 7
+#define STR_NOHOME_ID 0
+#define STR_INPUT_ID 1
+#define STR_INVBM_KEY 2
+#define STR_DATE_ID 3
+#define STR_TMPFILE 4
+#define STR_ARGLIMIT 5
static const char * const messages[] = {
- "nftw failed",
"HOME not set",
"no traversal",
"invalid key",
"%F %T %z",
- "unsafe cmd",
"/.nnnXXXXXX",
"one arg max",
};
close(fd);
if (pos && pos == copybufpos)
- spawn(pager, g_tmpfpath, NULL, NULL, F_PAGER);
+ spawn(pager, g_tmpfpath, NULL, NULL, F_CLI);
unlink(g_tmpfpath);
}
static void xrm(char *path)
{
if (cfg.trash)
- spawn("trash-put", path, NULL, NULL, F_NORMAL | F_SIGINT);
+ spawn("trash-put", path, NULL, NULL, F_NORMAL);
else {
char rm_opts[] = {'-', confirm_force(), 'r'};
- spawn("rm", rm_opts, path, NULL, F_NORMAL | F_SIGINT);
+ spawn("rm", rm_opts, path, NULL, F_NORMAL);
}
}
"cat %s | xargs -0 -o %s %s",
#endif
g_cppath, utils[APACK], archive);
- spawn("sh", "-c", g_buf, curpath, F_NORMAL | F_SIGINT);
+ spawn("sh", "-c", g_buf, curpath, F_NORMAL);
}
static bool write_lastdir(const char *curpath)
/* Show in pager in child */
dup2(pipefd[0], STDIN_FILENO);
close(pipefd[0]);
- spawn(pager, NULL, NULL, NULL, F_PAGER);
+ spawn(pager, NULL, NULL, NULL, F_CLI);
_exit(1);
}
dprintf(fd, "\n\n");
close(fd);
- spawn(pager, g_tmpfpath, NULL, NULL, F_PAGER);
+ spawn(pager, g_tmpfpath, NULL, NULL, F_CLI);
unlink(g_tmpfpath);
return TRUE;
}
dprintf(fd, "\nv%s\n%s\n", VERSION, GENERAL_INFO);
close(fd);
- spawn(pager, g_tmpfpath, NULL, NULL, F_PAGER);
+ spawn(pager, g_tmpfpath, NULL, NULL, F_CLI);
unlink(g_tmpfpath);
return TRUE;
}
refresh();
if (nftw(g_buf, nftw_fn, open_max,
FTW_MOUNT | FTW_PHYS) == -1) {
- DPRINTF_S(messages[STR_NFTWFAIL_ID]);
+ DPRINTF_S("nftw failed");
dir_blocks += (cfg.apparentsz
? sb.st_size
: sb.st_blocks);
xbasename(g_buf));
refresh();
if (nftw(g_buf, nftw_fn, open_max, FTW_MOUNT | FTW_PHYS) == -1) {
- DPRINTF_S(messages[STR_NFTWFAIL_ID]);
+ DPRINTF_S("nftw failed");
dentp->blocks = (cfg.apparentsz ? sb.st_size : sb.st_blocks);
} else
dentp->blocks = ent_blocks;
xstrlcpy(path, rundir, PATH_MAX);
if (runfile[0]) {
xstrlcpy(lastname, runfile, NAME_MAX);
- spawn(newpath, lastname, NULL, path,
- F_NORMAL | F_SIGINT);
+ spawn(newpath, lastname, NULL, path, F_NORMAL);
runfile[0] = '\0';
} else
- spawn(newpath, NULL, NULL, path, F_NORMAL | F_SIGINT);
+ spawn(newpath, NULL, NULL, path, F_NORMAL);
rundir[0] = '\0';
cfg.runscript = 0;
setdirwatch();
get_output(g_buf, CMD_LEN_MAX, "file", FILE_OPTS, newpath, FALSE)
&& g_buf[0] == 't' && g_buf[1] == 'e' && g_buf[2] == 'x'
&& g_buf[3] == g_buf[0] && g_buf[4] == '/') {
- spawn(editor, newpath, NULL, path, F_EDITOR);
+ spawn(editor, newpath, NULL, path, F_CLI);
continue;
}
r = show_help(path);
break;
case SEL_RUNEDIT:
- spawn(editor, dents[cur].name, NULL, path, F_EDITOR);
+ spawn(editor, dents[cur].name, NULL, path, F_CLI);
break;
case SEL_RUNPAGE:
- spawn(pager, dents[cur].name, NULL, path, F_PAGER);
+ spawn(pager, dents[cur].name, NULL, path, F_CLI);
break;
case SEL_NOTE:
{
goto nochange;
}
- spawn(editor, notepath, NULL, path, F_EDITOR);
+ spawn(editor, notepath, NULL, path, F_CLI);
break;
}
default: /* SEL_LOCK */
- spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL | F_SIGINT);
+ spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL);
break;
}
break;
}
- spawn("sh", "-c", g_buf, path, F_NORMAL | F_SIGINT);
+ spawn("sh", "-c", g_buf, path, F_NORMAL);
if (ndents)
copycurname();
mkpath(path, dents[cur].name, newpath);
DPRINTF_S(newpath);
- spawn(newpath, NULL, NULL, path, F_NORMAL | F_SIGINT);
+ spawn(newpath, NULL, NULL, path, F_NORMAL);
break;
case SEL_SHELL:
- spawn(shell, NULL, NULL, path, F_SHELL);
+ spawn(shell, NULL, NULL, path, F_CLI);
break;
case SEL_SCRIPT:
if (!scriptpath) {
/* Regular script file */
if (S_ISREG(sb.st_mode)) {
tmp = ndents ? dents[cur].name : NULL;
- spawn(scriptpath, tmp, NULL, path, F_NORMAL | F_SIGINT);
+ spawn(scriptpath, tmp, NULL, path, F_NORMAL);
break;
}
#endif
tmp = xreadline(NULL, "> ");
if (tmp[0])
- spawn(shell, "-c", tmp, path, F_SHELL);
+ spawn(shell, "-c", tmp, path, F_CLI);
#ifndef NORL
} else {
exitcurses();
refresh();
if (tmp && tmp[0]) {
- spawn(shell, "-c", tmp, path, F_SHELL);
+ spawn(shell, "-c", tmp, path, F_CLI);
/* readline finishing touches */
add_history(tmp);
free(tmp);
/* Locker */
if (idletimeout != 0 && idle == idletimeout) {
idle = 0;
- spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL | F_SIGINT);
+ spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL);
goto begin;
}