Doc fix.
[bpt/emacs.git] / lisp / env.el
1 ;;; setenv.el --- functions to manipulate environment variables.
2
3 ;;; Copyright Free Software Foundation 1991
4
5 ;; Maintainer: FSF
6 ;; Keywords: extensions
7
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
12 ;;; the Free Software Foundation; either version 2, or (at your option)
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
24 ;;; Code:
25
26 (defun setenv (variable value)
27 "Set the value of the environment variable named VARIABLE to VALUE.
28 VARIABLE and VALUE should both be strings.
29 This function works by modifying `process-environment'."
30 (interactive "sSet environment variable: \nsSet %s to value: ")
31 (if (string-match "=" variable)
32 (error "Environment variable name contains `='")
33 (let ((pattern (concat "\\`" (regexp-quote (concat variable "="))))
34 (scan process-environment))
35 (while scan
36 (cond
37 ((string-match pattern (car scan))
38 (setcar scan (concat variable "=" value))
39 (setq scan nil))
40 ((null (setq scan (cdr scan)))
41 (setq process-environment
42 (cons (concat variable "=" value) process-environment))))))))
43
44 (provide 'setenv)
45
46 ;;; setenv.el ends here