Don't distribute etc/Old files.
[bpt/emacs.git] / lisp / env.el
CommitLineData
c88ab9ce
ER
1;;; setenv.el --- functions to manipulate environment variables.
2
971571b9
ER
3;;; Copyright Free Software Foundation 1991
4
e5167999 5;; Maintainer: FSF
d7b4d18f 6;; Keywords: extensions
e5167999 7
6449c898
JB
8;;; This file is part of GNU Emacs.
9
10;;; GNU Emacs is free software; you can redistribute it and/or modify
11;;; it under the terms of the GNU General Public License as published by
e5167999 12;;; the Free Software Foundation; either version 2, or (at your option)
6449c898
JB
13;;; any later version.
14
15;;; GNU Emacs is distributed in the hope that it will be useful,
16;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Emacs; see the file COPYING. If not, write to
22;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
e5167999
ER
24;;; Code:
25
aa673ecc 26;;;###autoload
6449c898
JB
27(defun setenv (variable value)
28 "Set the value of the environment variable named VARIABLE to VALUE.
29VARIABLE and VALUE should both be strings.
b6a5978e 30This function works by modifying `process-environment'."
971571b9 31 (interactive "sSet environment variable: \nsSet %s to value: ")
6449c898 32 (if (string-match "=" variable)
971571b9
ER
33 (error "Environment variable name contains `='")
34 (let ((pattern (concat "\\`" (regexp-quote (concat variable "="))))
6449c898
JB
35 (scan process-environment))
36 (while scan
37 (cond
38 ((string-match pattern (car scan))
39 (setcar scan (concat variable "=" value))
40 (setq scan nil))
41 ((null (setq scan (cdr scan)))
42 (setq process-environment
43 (cons (concat variable "=" value) process-environment))))))))
49116ac0
JB
44
45(provide 'setenv)
46
c88ab9ce 47;;; setenv.el ends here