Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!stanford.edu!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!rearl From: rearl@gnu.ai.mit.edu (Robert Earl) Newsgroups: comp.unix.wizards Subject: Re: cd in the background? Message-ID: Date: 1 May 91 19:26:11 GMT References: <27756@hydra.gatech.EDU> Sender: news@ai.mit.edu Distribution: comp.unix.wizards Organization: (EVIL!) Lines: 24 In-reply-to: dsm@prism.gatech.EDU's message of 1 May 91 03:17:27 GMT In article <27756@hydra.gatech.EDU> dsm@prism.gatech.EDU (Daniel McGurl) writes: | In article gheim@eng.auburn.edu (Greg Heim) writes: | >I posted this question to comp.unix.questions and got no response... comp.unix.questions needs a lobotomy if nobody could answer it. That's a perfectly fine place to ask. Perhaps your news software is faulty. | >The other day I accidentally entered | | > cd /new/dir & | | >and my directory remained unchanged. Can anyone explain what is going on here? `cd' is a builtin command. The `&' forced the shell to spawn a child and execute the cd in a copy of itself, making this an effective no-op because a child cannot change a parent's working directory. | Here's the problem. Backgrounding creates a new shell for the process to | execute in. The process executes and does the CD in the newly spawned | shell. Then the shell dies and the old shells variable remain the way | they were. It has nothing to do with shell variables.