|
tmux environ.c, 1.3, 1.4 job.c, 1.15, 1.16 tmux.1, 1.244, 1.245 tmux.h,
1.554, 1.555 window.c, 1.129, 1.130
From: Nicholas Marriott <nicm@us...> - 2010-04-06 21:59
|
Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26321
Modified Files:
environ.c job.c tmux.1 tmux.h window.c
Log Message:
Run job commands explicitly in the global enviroment (which can be
modified with setenv -g) rather than with the environment tmux started
with.
Index: job.c
===================================================================
RCS file: /cvsroot/tmux/tmux/job.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- job.c 26 Feb 2010 13:35:04 -0000 1.15
+++ job.c 6 Apr 2010 21:59:19 -0000 1.16
@@ -149,7 +149,8 @@
return (-1);
case 0: /* child */
server_signal_clear();
- /* XXX environ? */
+
+ environ_push(&global_environ);
if (dup2(out[1], STDOUT_FILENO) == -1)
fatal("dup2 failed");
Index: environ.c
===================================================================
RCS file: /cvsroot/tmux/tmux/environ.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- environ.c 9 Aug 2009 17:57:39 -0000 1.3
+++ environ.c 6 Apr 2010 21:59:19 -0000 1.4
@@ -35,12 +35,14 @@
return (strcmp(envent1->name, envent2->name));
}
+/* Initialise the environment. */
void
environ_init(struct environ *env)
{
RB_INIT(env);
}
+/* Free an environment. */
void
environ_free(struct environ *env)
{
@@ -56,6 +58,7 @@
}
}
+/* Copy one environment into another. */
void
environ_copy(struct environ *srcenv, struct environ *dstenv)
{
@@ -65,6 +68,7 @@
environ_set(dstenv, envent->name, envent->value);
}
+/* Find an environment variable. */
struct environ_entry *
environ_find(struct environ *env, const char *name)
{
@@ -74,6 +78,7 @@
return (RB_FIND(environ, env, &envent));
}
+/* Set an environment variable. */
void
environ_set(struct environ *env, const char *name, const char *value)
{
@@ -97,10 +102,11 @@
}
}
+/* Set an environment variable from a NAME=VALUE string. */
void
environ_put(struct environ *env, const char *var)
{
- char *name, *value;
+ char *name, *value;
value = strchr(var, '=');
if (value == NULL)
@@ -114,6 +120,7 @@
xfree(name);
}
+/* Unset an environment variable. */
void
environ_unset(struct environ *env, const char *name)
{
@@ -128,6 +135,10 @@
xfree(envent);
}
+/*
+ * Copy a space-separated list of variables from a destination into a source
+ * environment.
+ */
void
environ_update(const char *vars, struct environ *srcenv, struct environ *dstenv)
{
@@ -143,3 +154,28 @@
}
xfree(copyvars);
}
+
+/* Push environment into the real environment - use after fork(). */
+void
+environ_push(struct environ *env)
+{
+ ARRAY_DECL(, char *) varlist;
+ struct environ_entry *envent;
+ char **varp, *var;
+ u_int i;
+
+ ARRAY_INIT(&varlist);
+ for (varp = environ; *varp != NULL; varp++) {
+ var = xstrdup(*varp);
+ var[strcspn(var, "=")] = '\0';
+ ARRAY_ADD(&varlist, var);
+ }
+ for (i = 0; i < ARRAY_LENGTH(&varlist); i++)
+ unsetenv(ARRAY_ITEM(&varlist, i));
+ ARRAY_FREE(&varlist);
+
+ RB_FOREACH(envent, environ, env) {
+ if (envent->value != NULL)
+ setenv(envent->name, envent->value, 1);
+ }
+}
Index: window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/window.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- window.c 6 Apr 2010 21:58:33 -0000 1.129
+++ window.c 6 Apr 2010 21:59:19 -0000 1.130
@@ -478,14 +478,11 @@
window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
const char *cwd, struct environ *env, struct termios *tio, char **cause)
{
- struct winsize ws;
- int mode;
- char *argv0, **varp, *var;
- ARRAY_DECL(, char *) varlist;
- struct environ_entry *envent;
- const char *ptr;
- struct termios tio2;
- u_int i;
+ struct winsize ws;
+ int mode;
+ char *argv0;
+ const char *ptr;
+ struct termios tio2;
if (wp->fd != -1) {
close(wp->fd);
@@ -528,20 +525,7 @@
if (tcsetattr(STDIN_FILENO, TCSANOW, &tio2) != 0)
fatal("tcgetattr failed");
- ARRAY_INIT(&varlist);
- for (varp = environ; *varp != NULL; varp++) {
- var = xstrdup(*varp);
- var[strcspn(var, "=")] = '\0';
- ARRAY_ADD(&varlist, var);
- }
- for (i = 0; i < ARRAY_LENGTH(&varlist); i++) {
- var = ARRAY_ITEM(&varlist, i);
- unsetenv(var);
- }
- RB_FOREACH(envent, environ, env) {
- if (envent->value != NULL)
- setenv(envent->name, envent->value, 1);
- }
+ environ_push(env);
server_signal_clear();
log_close();
Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.554
retrieving revision 1.555
diff -u -d -r1.554 -r1.555
--- tmux.h 6 Apr 2010 21:58:33 -0000 1.554
+++ tmux.h 6 Apr 2010 21:59:19 -0000 1.555
@@ -1330,6 +1330,7 @@
void environ_put(struct environ *, const char *);
void environ_unset(struct environ *, const char *);
void environ_update(const char *, struct environ *, struct environ *);
+void environ_push(struct environ *);
/* tty.c */
void tty_raw(struct tty *, const char *);
Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.244
retrieving revision 1.245
diff -u -d -r1.244 -r1.245
--- tmux.1 5 Apr 2010 05:11:44 -0000 1.244
+++ tmux.1 6 Apr 2010 21:59:19 -0000 1.245
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 27 2010 $
+.Dd $Mdocdate: April 4 2010 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1743,6 +1743,10 @@
.Ic status-interval
option: if the status line is redrawn in the meantime, the previous result is
used.
+Shell commands are executed with the
+.Nm
+global environment set (see the
+.Sx ENVIRONMENT section).
.Pp
#[attributes] allows a comma-separated list of attributes to be specified,
these may be
|
| Thread | Author | Date |
|---|---|---|
| tmux environ.c, 1.3, 1.4 job.c, 1.15, 1.16 tmux.1, 1.244, 1.245 tmux.h, 1.554, 1.555 window.c, 1.129, 1.130 | Nicholas Marriott <nicm@us...> |