annotate lisp/env.el @ 748:4714ad36583c

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Tue, 07 Jul 1992 18:36:02 +0000
parents 7cbd4fcd8b0f
children 4f28bd14272c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; setenv.el --- functions to manipulate environment variables.
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
489
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3 ;;; Copyright Free Software Foundation 1991
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 ;;; This file is part of GNU Emacs.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 ;;; GNU Emacs is free software; you can redistribute it and/or modify
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;;; it under the terms of the GNU General Public License as published by
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;;; the Free Software Foundation; either version 1, or (at your option)
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;;; any later version.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;;; GNU Emacs is distributed in the hope that it will be useful,
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;;; GNU General Public License for more details.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;;; You should have received a copy of the GNU General Public License
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;;; along with GNU Emacs; see the file COPYING. If not, write to
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 (defun setenv (variable value)
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 "Set the value of the environment variable named VARIABLE to VALUE.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 VARIABLE and VALUE should both be strings.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 This function works by modifying process-environment."
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 (if (string-match "=" variable)
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 (error "name of environment variable contains an '=' character")
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 (let ((pattern (concat "^" (regexp-quote (concat variable "="))))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 (scan process-environment))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 (while scan
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 (cond
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ((string-match pattern (car scan))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 (setcar scan (concat variable "=" value))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 (setq scan nil))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ((null (setq scan (cdr scan)))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 (setq process-environment
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 (cons (concat variable "=" value) process-environment))))))))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 489
diff changeset
37
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 489
diff changeset
38 (provide 'setenv)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 489
diff changeset
39
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
40 ;;; setenv.el ends here