Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!cbfsb!cbnewsb.cb.att.com!pfinkel From: pfinkel@cbnewsb.cb.att.com (paul.d.finkel) Newsgroups: comp.unix.programmer Subject: Re: how to change parent environment? Message-ID: <1991May14.161037.25742@cbfsb.att.com> Date: 14 May 91 16:10:37 GMT References: <1991May2.194624.21819@kong.gsfc.nasa.gov> Sender: news@cbfsb.att.com Distribution: usa Organization: AT&T Bell Laboratories Lines: 23 In article <1991May2.194624.21819@kong.gsfc.nasa.gov> njacobs@kong.gsfc.nasa.gov (Nick Jacobs - EOS) writes: >How do you change the current working directory in a program, so >that when the program is invoked from a shell, the cwd stays >changed after the program exits? >You can't do it with chdir(2) of course, because that only affects >the current process. > >Nick You could run it from a shell function: $pwd /usr/bin $go_go() { cd /etc your_command pwd } $go_go /etc $pwd /etc