Path: utzoo!attcan!uunet!lll-winken!ames!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: Set parent env with csh script Message-ID: <15344@mimsy.UUCP> Date: 8 Jan 89 05:55:14 GMT References: <174@v7fs1.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 27 In article <174@v7fs1.UUCP> mvp@v7fs1.UUCP (Mike Van Pelt) writes: >Is it possible for a subshell to changes the calling shell's environment? Yes. >How? By getting the cooperation of the calling shell. For instance: #! /bin/sh # edit environment variable case $# in 1);; *) echo "usage: edit-env varname" 1>&2; exit 1;; esac TF=${TMPDIR-/tmp}/edenv$$ rm -f $TF trap 'rm -f $TF; exit 1' 1 2 3 15 trap 'rm -f $TF; exit' 0 eval echo "$1" > $TF if ${EDITOR-vi} $TF /dev/tty 2>&1; then echo "setenv $1 `cat $TF`" # csh-specific fi Then: % alias edit-env 'eval `~/bin/edit-env`' -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris