1 ;;; setenv.el --- functions to manipulate environment variables.
3 ;;; Copyright Free Software Foundation 1991
5 ;;; This file is part of GNU Emacs.
7 ;;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;;; it under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 1, or (at your option)
10 ;;; any later version.
12 ;;; GNU Emacs is distributed in the hope that it will be useful,
13 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 (defun setenv (variable value
)
22 "Set the value of the environment variable named VARIABLE to VALUE.
23 VARIABLE and VALUE should both be strings.
24 This function works by modifying process-environment."
25 (if (string-match "=" variable
)
26 (error "name of environment variable contains an '=' character")
27 (let ((pattern (concat "^" (regexp-quote (concat variable
"="))))
28 (scan process-environment
))
31 ((string-match pattern
(car scan
))
32 (setcar scan
(concat variable
"=" value
))
34 ((null (setq scan
(cdr scan
)))
35 (setq process-environment
36 (cons (concat variable
"=" value
) process-environment
))))))))
40 ;;; setenv.el ends here