home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!data.nas.nasa.gov!ace.nas.nasa.gov!jns
- From: jns@ace.nas.nasa.gov (John N. Stewart)
- Subject: Re: how to change shell's PWD(directory) from a C program?
- References: <1hqe2cINN6ot@usenet.INS.CWRU.Edu> <C02648.Jq@bc3.GUN.de>
- Sender: news@nas.nasa.gov (News Administrator)
- Organization: NAS, NASA Ames Research Center, Moffett Field, California
- Date: Wed, 30 Dec 92 23:59:28 GMT
- Message-ID: <1992Dec30.235928.8810@nas.nasa.gov>
- Lines: 32
-
- In article <C02648.Jq@bc3.GUN.de> ktf@bc3.GUN.de (Klaus ter Fehn) writes:
- >In article <1hqe2cINN6ot@usenet.INS.CWRU.Edu> cl820@cleveland.Freenet.Edu (Wei Jin Mai) writes:
- >> Here is what I want to do: UPon the termination of my program, I
- >>want to change to another directory . Normally, a program exit to the
- >>directory that invoke it.
- >
- >Because of the current newsgroup (comp.unix.questions) I assume, that
- >you're programming under the UNIX-environment. Note, that the PWD (Path
- >of Working Directory) is an environment-held information of a
- >process.
-
-
- No, actually it isn't. The PWD is a function of certain shells, not
- processes. You can't really assume it is there, or for that matter, it
- is dangerous to assume it is correct.
-
- Frankly, changing the cwd of a parent process ain't "possible" from a
- child, since that child has no control over the parent (FAQ). The next
- best thing I can imagine is to have the parent process "cd" to a
- directory returned by the exit status or something of that nature.
- Something like:
-
- Pseudo:
-
- #!insert your favourite shell here
-
- cd `program`
-
-
- where program returns the new directory to be "cd"'ed to.
-
- --Ace
-