diff options
author | Jesse Luehrs <doy@tozt.net> | 2016-05-14 17:32:34 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2016-05-14 17:33:20 -0400 |
commit | bfe96a6aa5fa3ca9a05b658efbcaee9dc01b5235 (patch) | |
tree | f32a44cd6676acbdbcc685a0782e6d51889efaf0 /src/pty-unix.c | |
parent | 1c3406e8b486ec22f16d4e5bf6a28d35ca744af3 (diff) | |
download | runes-bfe96a6aa5fa3ca9a05b658efbcaee9dc01b5235.tar.gz runes-bfe96a6aa5fa3ca9a05b658efbcaee9dc01b5235.zip |
support spawning terminals with different environments
Diffstat (limited to 'src/pty-unix.c')
-rw-r--r-- | src/pty-unix.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/pty-unix.c b/src/pty-unix.c index ba4ea34..376a92d 100644 --- a/src/pty-unix.c +++ b/src/pty-unix.c @@ -18,6 +18,8 @@ #include "term.h" #include "window-xlib.h" +extern char **environ; + static int runes_pty_input_cb(void *t); RunesPty *runes_pty_new() @@ -32,7 +34,7 @@ RunesPty *runes_pty_new() return pty; } -void runes_pty_spawn_subprocess(RunesTerm *t) +void runes_pty_spawn_subprocess(RunesTerm *t, char *envp[], char *cwd) { RunesPty *pty = t->pty; @@ -90,6 +92,14 @@ void runes_pty_spawn_subprocess(RunesTerm *t) unsetenv("LINES"); unsetenv("COLUMNS"); + if (cwd) { + chdir(cwd); + } + + if (envp) { + environ = envp; + } + if (strpbrk(cmd, " $")) { execlp("/bin/sh", "/bin/sh", "-c", cmd, (char *)NULL); } |