aboutsummaryrefslogtreecommitdiffstats
path: root/src/pty-unix.c
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2016-05-14 17:32:34 -0400
committerJesse Luehrs <doy@tozt.net>2016-05-14 17:33:20 -0400
commitbfe96a6aa5fa3ca9a05b658efbcaee9dc01b5235 (patch)
treef32a44cd6676acbdbcc685a0782e6d51889efaf0 /src/pty-unix.c
parent1c3406e8b486ec22f16d4e5bf6a28d35ca744af3 (diff)
downloadrunes-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.c12
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);
}