unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23779: 25.0.95; consing "SHELLVAR" onto process-environment doesn't remove it from subprocess env
@ 2016-06-17  3:33 Noam Postavsky
  2016-06-17  7:11 ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Noam Postavsky @ 2016-06-17  3:33 UTC (permalink / raw)
  To: 23779

Start emacs -Q, evaluate the following lisp code (I wrote the return
values after ;=>)

(defun check-env-var (var)
  (catch 'ret
    (dolist (var=val (process-lines "env"))
      (when (string-prefix-p var var=val)
        (throw 'ret var=val)))))

(check-env-var "SHELL");=>"SHELL=/bin/bash"
(let ((process-environment (copy-sequence process-environment)))
  (setenv "SHELL" nil)
  (check-env-var "SHELL"));=>nil
(let ((process-environment (cons "SHELL" process-environment)))
  (check-env-var "SHELL"));=>"SHELL=/bin/bash"
(let ((process-environment (cons "SHELL=" process-environment)))
  (check-env-var "SHELL"));=>"SHELL="

As you can see from the 3rd expression, contrary to its docstring,
consing the env variable "SHELL" onto process-environment has no
effect at all.

process-environment is a variable defined in ‘C source code’.
Its value is
[...]
Documentation:
List of overridden environment variables for subprocesses to inherit.
Each element should be a string of the form ENVVARNAME=VALUE.

Entries in this list take precedence to those in the frame-local
environments.  Therefore, let-binding ‘process-environment’ is an easy
way to temporarily change the value of an environment variable,
irrespective of where it comes from.  To use ‘process-environment’ to
remove an environment variable, include only its name in the list,
without "=VALUE".





^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2016-06-21 23:05 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17  3:33 bug#23779: 25.0.95; consing "SHELLVAR" onto process-environment doesn't remove it from subprocess env Noam Postavsky
2016-06-17  7:11 ` Eli Zaretskii
2016-06-17 12:17   ` Dmitry Gutov
2016-06-17 14:01     ` Eli Zaretskii
2016-06-17 14:12       ` Dmitry Gutov
2016-06-17 14:19         ` Eli Zaretskii
2016-06-17 14:47           ` Dmitry Gutov
2016-06-17 16:52             ` Andreas Schwab
2016-06-17 16:55               ` Dmitry Gutov
2016-06-17 17:06             ` Eli Zaretskii
2016-06-17 19:01               ` Dmitry Gutov
2016-06-17 20:10                 ` Eli Zaretskii
2016-06-17 21:26                   ` Dmitry Gutov
2016-06-18  7:51                     ` Eli Zaretskii
2016-06-18  1:36             ` Noam Postavsky
2016-06-18  1:44               ` Dmitry Gutov
2016-06-19  2:27           ` Paul Eggert
2016-06-19 15:01             ` Eli Zaretskii
2016-06-19 22:53               ` Paul Eggert
2016-06-20 14:21                 ` Eli Zaretskii
2016-06-21 13:53                   ` Dmitry Gutov
2016-06-21 15:21                     ` Eli Zaretskii
2016-06-21 15:24                       ` Dmitry Gutov
2016-06-21 16:12                         ` Eli Zaretskii
2016-06-21 23:05                           ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).