aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
authorStefan Monnier2007-08-31 04:39:24 +0000
committerStefan Monnier2007-08-31 04:39:24 +0000
commit6b8e474c53700bb1d039abf8a563c042bde5e0ee (patch)
treef166a5c7c6687e031f99bd3c5be30ac54500f834 /src/callproc.c
parent3b44dbc50ca405d93c8b4a11ede9573f23c240a2 (diff)
downloademacs-6b8e474c53700bb1d039abf8a563c042bde5e0ee.tar.gz
emacs-6b8e474c53700bb1d039abf8a563c042bde5e0ee.zip
(Vinitial_environment): New variable.
(set_initial_environment): Initialize it. (syms_of_callproc): Declare it. (child_setup): Don't mess with TERM via Qterm_environment_variable; the TERM under which a process runs is never related to the TERM in which Emacs is running.
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 5bd4cee9cfa..66d11ff402c 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -113,7 +113,7 @@ Lisp_Object Vtemp_file_name_pattern;
113 113
114Lisp_Object Vshell_file_name; 114Lisp_Object Vshell_file_name;
115 115
116Lisp_Object Vprocess_environment; 116Lisp_Object Vprocess_environment, Vinitial_environment;
117 117
118#ifdef DOS_NT 118#ifdef DOS_NT
119Lisp_Object Qbuffer_file_type; 119Lisp_Object Qbuffer_file_type;
@@ -1330,7 +1330,6 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
1330 Lisp_Object local = selected_frame; /* get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), */ 1330 Lisp_Object local = selected_frame; /* get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), */
1331/* Qenvironment); */ 1331/* Qenvironment); */
1332 1332
1333 Lisp_Object term;
1334 Lisp_Object display; 1333 Lisp_Object display;
1335 1334
1336 new_length = 0; 1335 new_length = 0;
@@ -1347,33 +1346,19 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
1347 new_length++; 1346 new_length++;
1348#endif 1347#endif
1349 1348
1350 /* Add TERM and DISPLAY from the frame local values. */ 1349 /* Add DISPLAY from the frame local values. */
1351 term = get_frame_param (XFRAME (local), Qterm_environment_variable);
1352 if (! NILP (term))
1353 new_length++;
1354
1355 display = get_frame_param (XFRAME (local), Qdisplay_environment_variable); 1350 display = get_frame_param (XFRAME (local), Qdisplay_environment_variable);
1356 if (! NILP (display)) 1351 if (! NILP (display))
1357 new_length++; 1352 new_length++;
1358 1353
1359 /* new_length + 2 to include PWD and terminating 0. */ 1354 /* new_length + 2 to include PWD and terminating 0. */
1360 env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *)); 1355 env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *));
1361
1362 /* If we have a PWD envvar, pass one down, 1356 /* If we have a PWD envvar, pass one down,
1363 but with corrected value. */ 1357 but with corrected value. */
1364 if (egetenv ("PWD")) 1358 if (egetenv ("PWD"))
1365 *new_env++ = pwd_var; 1359 *new_env++ = pwd_var;
1366 1360
1367 if (! NILP (term)) 1361 if (STRINGP (display))
1368 {
1369 int vlen = strlen ("TERM=") + strlen (SDATA (term)) + 1;
1370 char *vdata = (char *) alloca (vlen);
1371 strcpy (vdata, "TERM=");
1372 strcat (vdata, SDATA (term));
1373 new_env = add_env (env, new_env, vdata);
1374 }
1375
1376 if (! NILP (display))
1377 { 1362 {
1378 int vlen = strlen ("DISPLAY=") + strlen (SDATA (display)) + 1; 1363 int vlen = strlen ("DISPLAY=") + strlen (SDATA (display)) + 1;
1379 char *vdata = (char *) alloca (vlen); 1364 char *vdata = (char *) alloca (vlen);
@@ -1387,8 +1372,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
1387 CONSP (tem) && STRINGP (XCAR (tem)); 1372 CONSP (tem) && STRINGP (XCAR (tem));
1388 tem = XCDR (tem)) 1373 tem = XCDR (tem))
1389 { 1374 {
1390 if ((strcmp (SDATA (XCAR (tem)), "TERM") != 0) 1375 if (strcmp (SDATA (XCAR (tem)), "DISPLAY") != 0)
1391 && (strcmp (SDATA (XCAR (tem)), "DISPLAY") != 0))
1392 new_env = add_env (env, new_env, SDATA (XCAR (tem))); 1376 new_env = add_env (env, new_env, SDATA (XCAR (tem)));
1393 } 1377 }
1394 1378
@@ -1539,7 +1523,8 @@ getenv_internal (var, varlen, value, valuelen, frame)
1539 Lisp_Object scan; 1523 Lisp_Object scan;
1540 Lisp_Object term; 1524 Lisp_Object term;
1541 Lisp_Object display; 1525 Lisp_Object display;
1542 1526
1527 /* FIXME: Code duplication. */
1543 1528
1544 if (NILP (frame)) 1529 if (NILP (frame))
1545 { 1530 {
@@ -1843,6 +1828,9 @@ set_initial_environment ()
1843 Vprocess_environment); 1828 Vprocess_environment);
1844 store_frame_param (SELECTED_FRAME(), Qenvironment, Vprocess_environment); 1829 store_frame_param (SELECTED_FRAME(), Qenvironment, Vprocess_environment);
1845 } 1830 }
1831 /* Ideally, the `copy' shouldn't be necessary, but it seems it's frequent
1832 to use `delete' and friends on process-environment. */
1833 Vinitial_environment = Fcopy_sequence (Vprocess_environment);
1846} 1834}
1847 1835
1848void 1836void
@@ -1901,6 +1889,12 @@ If this variable is nil, then Emacs is unable to use a shared directory. */);
1901This is used by `call-process-region'. */); 1889This is used by `call-process-region'. */);
1902 /* This variable is initialized in init_callproc. */ 1890 /* This variable is initialized in init_callproc. */
1903 1891
1892 DEFVAR_LISP ("initial-environment", &Vinitial_environment,
1893 doc: /* List of environment variables inherited from the parent process.
1894Each element should be a string of the form ENVVARNAME=VALUE.
1895The elements must normally be decoded (using `locale-coding-system') for use. */);
1896 Vinitial_environment = Qnil;
1897
1904 DEFVAR_LISP ("process-environment", &Vprocess_environment, 1898 DEFVAR_LISP ("process-environment", &Vprocess_environment,
1905 doc: /* List of overridden environment variables for subprocesses to inherit. 1899 doc: /* List of overridden environment variables for subprocesses to inherit.
1906Each element should be a string of the form ENVVARNAME=VALUE. 1900Each element should be a string of the form ENVVARNAME=VALUE.