aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/progman.c')
-rw-r--r--src/progman.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/progman.c b/src/progman.c
index b9a0f5f..4474b38 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -479,13 +479,20 @@ progman_start(int type, listener_t *lp, struct grecs_locus *loc,
fd_set fdset;
struct wordsplit ws;
- int flags = WRDSF_NOCMD | WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS |
- WRDSF_CESCAPES;
+ int flags = WRDSF_NOCMD;
if (kve) {
ws.ws_env = (const char **) kve;
flags |= WRDSF_ENV | WRDSF_ENV_KV;
}
+
+ if (options & OPT_SHELL) {
+ ws.ws_offs = 2;
+ flags |= WRDSF_NOSPLIT | WRDSF_DOOFFS;
+ } else {
+ flags |= WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS |
+ WRDSF_CESCAPES;
+ }
if (wordsplit(prog, &ws, flags)) {
diag(LOG_CRIT, "%s:%d: wordsplit: %s",
@@ -493,6 +500,10 @@ progman_start(int type, listener_t *lp, struct grecs_locus *loc,
wordsplit_strerror(&ws));
return -1;
}
+ if (options & OPT_SHELL) {
+ ws.ws_wordv[0] = "/bin/sh";
+ ws.ws_wordv[1] = "-c";
+ }
if (config.debug_level >= 1) {
int i;
@@ -501,7 +512,7 @@ progman_start(int type, listener_t *lp, struct grecs_locus *loc,
size_t locsize = 0;
grecs_txtacc_grow_string(acc, ws.ws_wordv[0]);
- for (i = 1; i < ws.ws_wordc; i++) {
+ for (i = 1; i < ws.ws_wordc + ws.ws_offs; i++) {
grecs_txtacc_grow_char(acc, ' ');
grecs_txtacc_grow_string_escape(acc, ws.ws_wordv[i]);
}

Return to:

Send suggestions and report system problems to the System administrator.