Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site psivax.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!qantel!hplabs!sdcrdcf!psivax!friesen From: friesen@psivax.UUCP (Stanley Friesen) Newsgroups: net.unix Subject: Re: Can anyone explain? Message-ID: <614@psivax.UUCP> Date: Fri, 2-Aug-85 18:19:43 EDT Article-I.D.: psivax.614 Posted: Fri Aug 2 18:19:43 1985 Date-Received: Sun, 4-Aug-85 10:37:56 EDT References: <118@wgivax.UUCP> Reply-To: friesen@psivax.UUCP (Stanley Friesen) Organization: Pacesetter Systems Inc., Sylmar, CA Lines: 33 In article <118@wgivax.UUCP> ram@wgivax.UUCP (Rick Messinger #4975) writes: > > In this sh scipt is a sequence of two events. > >> : Copy a file to a directory then chdir to the given dir >> case $# in >> 2) cp $1 $2/$1 ; cd $2 ;; >> *) echo 'Usage: ccarry file dir/path' ;; >> esac > > Due to the design of the shell, it does not work (not in actuality anyway). >Does anyone out there know of a way this can be done. I got word it could >be done in C? I'll be interested to find out. Well, the problem is not the design of the shell, it is the design of the kernel! The current directory is an attribute of a *process*, not a user or login session, and as such it may only be passed *downwards* to children, not upwards to the parent. Thus even a C program would fail, since it also would run as a child process. The solution is to get the command sequence interpreted directly by the interactive shell rather than in a sub-shell. Csh has two ways of doing this, "alias" and "source". For something like this I usually combine both. That is I set up an alias to "source" the script. Unfortunately, the sh equivalent of "source", the "." command, does not pass arguments to the script being interpreted, so it will not work, and shell variable expansion does not provide for arguments either, so you have no general equivalent of the alias feature! -- Sarima (Stanley Friesen) {trwrb|allegra|cbosgd|hplabs|ihnp4|aero!uscvax!akgua}!sdcrdcf!psivax!friesen or {ttdica|quad1|bellcore|scgvaxd}!psivax!friesen