Mercurial > emacs
comparison src/callproc.c @ 83796:e7303426ed25
(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.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 31 Aug 2007 04:39:24 +0000 |
parents | 5b644ae74c91 |
children | 6aa4d1effd67 |
comparison
equal
deleted
inserted
replaced
83795:5ebc9b06e580 | 83796:e7303426ed25 |
---|---|
111 Lisp_Object Vconfigure_info_directory, Vshared_game_score_directory; | 111 Lisp_Object Vconfigure_info_directory, Vshared_game_score_directory; |
112 Lisp_Object Vtemp_file_name_pattern; | 112 Lisp_Object Vtemp_file_name_pattern; |
113 | 113 |
114 Lisp_Object Vshell_file_name; | 114 Lisp_Object Vshell_file_name; |
115 | 115 |
116 Lisp_Object Vprocess_environment; | 116 Lisp_Object Vprocess_environment, Vinitial_environment; |
117 | 117 |
118 #ifdef DOS_NT | 118 #ifdef DOS_NT |
119 Lisp_Object Qbuffer_file_type; | 119 Lisp_Object Qbuffer_file_type; |
120 #endif /* DOS_NT */ | 120 #endif /* DOS_NT */ |
121 | 121 |
1328 char **p, **q; | 1328 char **p, **q; |
1329 register int new_length; | 1329 register int new_length; |
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; |
1337 | 1336 |
1338 for (tem = Vprocess_environment; | 1337 for (tem = Vprocess_environment; |
1345 CONSP (tem) && STRINGP (XCAR (tem)); | 1344 CONSP (tem) && STRINGP (XCAR (tem)); |
1346 tem = XCDR (tem)) | 1345 tem = XCDR (tem)) |
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); |
1380 strcpy (vdata, "DISPLAY="); | 1365 strcpy (vdata, "DISPLAY="); |
1381 strcat (vdata, SDATA (display)); | 1366 strcat (vdata, SDATA (display)); |
1385 /* Overrides. */ | 1370 /* Overrides. */ |
1386 for (tem = Vprocess_environment; | 1371 for (tem = Vprocess_environment; |
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 |
1395 | 1379 |
1396 #if 0 | 1380 #if 0 |
1537 Lisp_Object frame; | 1521 Lisp_Object frame; |
1538 { | 1522 { |
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 { |
1546 /* Try to find VAR in Vprocess_environment first. */ | 1531 /* Try to find VAR in Vprocess_environment first. */ |
1547 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan)) | 1532 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan)) |
1841 for (envp = environ; *envp; envp++) | 1826 for (envp = environ; *envp; envp++) |
1842 Vprocess_environment = Fcons (build_string (*envp), | 1827 Vprocess_environment = Fcons (build_string (*envp), |
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 |
1848 void | 1836 void |
1849 syms_of_callproc () | 1837 syms_of_callproc () |
1850 { | 1838 { |
1899 DEFVAR_LISP ("temp-file-name-pattern", &Vtemp_file_name_pattern, | 1887 DEFVAR_LISP ("temp-file-name-pattern", &Vtemp_file_name_pattern, |
1900 doc: /* Pattern for making names for temporary files. | 1888 doc: /* Pattern for making names for temporary files. |
1901 This is used by `call-process-region'. */); | 1889 This 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. | |
1894 Each element should be a string of the form ENVVARNAME=VALUE. | |
1895 The 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. |
1906 Each element should be a string of the form ENVVARNAME=VALUE. | 1900 Each element should be a string of the form ENVVARNAME=VALUE. |
1907 | 1901 |
1908 Entries in this list take precedence to those in the frame-local | 1902 Entries in this list take precedence to those in the frame-local |