2016-01-03 13:22:17 (UTC-02:00)
Marcel Rodrigues <marcelgmr@gmail.com>
Make use of shell optional.
diff --git a/config.h b/config.h index 866a659..b6a74d7 100644 --- a/config.h +++ b/config.h @@ -67,5 +67,13 @@ /* Optional macro to be executed when a batch operation finishes. */ #define RV_ALERT() beep() -/* Shell used to launch external programs. */ +/* Shell used to launch external programs. + Defining this macro will force Rover to launch external + programs with `sh -c "$EXTERNAL_PROGRAM [arg]"`. This gives more + flexibility, allowing command-line arguments to be embedded in + environment variables (e.g. PAGER="less -N"). On the other hand, + this requires the presence of a shell and will spawn an additional + process each time an external program is invoked. Leave this macro + undefined if you prefer external programs to be launched with just + `$EXTERNAL_PROGRAM [arg]`. */ #define RV_SHELL "/bin/sh" diff --git a/rover.c b/rover.c index 3dca3b5..ef44d7b 100644 --- a/rover.c +++ b/rover.c @@ -1074,28 +1074,40 @@ main(int argc, char *argv[]) } else if (!strcmp(key, RVK_SHELL)) { program = getenv("SHELL"); if (program) { +#ifdef RV_SHELL spawn((char *[]) {RV_SHELL, "-c", program, NULL}); +#else + spawn((char *[]) {program, NULL}); +#endif reload(); } } else if (!strcmp(key, RVK_VIEW)) { if (!rover.nfiles || S_ISDIR(EMODE(ESEL))) continue; program = getenv("PAGER"); if (program) { +#ifdef RV_SHELL strncpy(BUF1, program, BUFLEN - 1); strncat(BUF1, " ", BUFLEN - strlen(program) - 1); strncat(BUF1, ENAME(ESEL), BUFLEN - strlen(program) - strlen(ENAME(ESEL)) - 2); spawn((char *[]) {RV_SHELL, "-c", BUF1, NULL}); +#else + spawn((char *[]) {program, ENAME(ESEL), NULL}); +#endif } } else if (!strcmp(key, RVK_EDIT)) { if (!rover.nfiles || S_ISDIR(EMODE(ESEL))) continue; program = getenv("EDITOR"); if (program) { +#ifdef RV_SHELL strncpy(BUF1, program, BUFLEN - 1); strncat(BUF1, " ", BUFLEN - strlen(program) - 1); strncat(BUF1, ENAME(ESEL), BUFLEN - strlen(program) - strlen(ENAME(ESEL)) - 2); spawn((char *[]) {RV_SHELL, "-c", BUF1, NULL}); +#else + spawn((char *[]) {program, ENAME(ESEL), NULL}); +#endif cd(0); } } else if (!strcmp(key, RVK_SEARCH)) {