Temporary Modified Environment during External Process Call from Emacs
Asked Answered
B

2

3

Is there a convenient and functional (with-...-like) way of temporary modifying environment variables when using shell-comand or start-process?

Thanks in advance, Per

Brassbound answered 26/6, 2011 at 12:23 Comment(0)
K
2

server-with-environment looks promising.

server-with-environment is a Lisp macro in `server.el'.

(server-with-environment ENV VARS &rest BODY)

Evaluate BODY with environment variables VARS set to those in ENV. The environment variables are then restored to their previous values.

VARS should be a list of strings. ENV should be in the same format as `process-environment'.

Klapp answered 26/6, 2011 at 13:7 Comment(0)
F
8

process-environment is a List of overridden environment variables for subprocesses to inherit.

(let ((process-environment (cons "FOO=BAR" process-environment)))
  (shell-command-to-string "echo $FOO"))

->

BAR
Faddish answered 26/6, 2011 at 16:43 Comment(0)
K
2

server-with-environment looks promising.

server-with-environment is a Lisp macro in `server.el'.

(server-with-environment ENV VARS &rest BODY)

Evaluate BODY with environment variables VARS set to those in ENV. The environment variables are then restored to their previous values.

VARS should be a list of strings. ENV should be in the same format as `process-environment'.

Klapp answered 26/6, 2011 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.