Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!cs.umn.edu!sialis!quad!dts From: dts@quad.sialis.com (David Sandberg) Newsgroups: comp.unix.questions Subject: Re: using cd command in a file Message-ID: <680@quad.sialis.com> Date: 27 May 91 21:26:12 GMT Article-I.D.: quad.680 References: <1991May20.201923.27920@garfield.ncat.edu> <9105230900.22@rmkhome.UUCP> <1991May27.170005.12870@xzaphod.uucp> Organization: Quadric Systems Lines: 37 In article <1991May27.170005.12870@xzaphod.uucp> michael@xzaphod.UUCP (Michael R. Miller) writes: >A script won't work because "cd" is a "built in" command in every shell >I've heard of. Whether cd is builtin or not has nothing to do with the reason a "cd script" won't work. Rather, it's because each process has it's own idea of what is the current working directory. New processes inherit the current working directory from their parent process, but not visa versa. I also have to wonder why you made the above statement when, in the very next paragraph, you described why a "cd script" doesn't work in an essentially correct fashion. But then you got screwed up again and closed your article with the following: >A modification to the script command could be: > >#!/bin/sh >exec $SHELL -c "cd /me/A/B/C/D" Huh? I hate to tell you this, but your modified script won't work any better than the original, since you're still running the cd command in a subshell. In fact, your suggested change makes it worse if anything... it accomplishes the same thing as the other (nothing, that is) and takes more processes to do it. >If your shell supports aliases (/bin/ksh, /bin/csh, /bin/zsh), use it. Agreed. I said as much a week ago via email to the original person who posed the question, thinking that it was too obvious of a question to post a public reply to. Heh... I should've known better, I guess. -- \*=- David Sandberg, dts@quad.sialis.com ,=, ,=, -=*\ \*=- "like words whispered by waking ghosts | |uadric `=,ystems -=*\ \*=- that in my ears muttered" - Torhthelm `=\ `=' -=*\