Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hcrvx1.UUCP Path: utzoo!hcrvax!hcrvx1!don From: don@hcrvx1.UUCP (Don McKillican) Newsgroups: net.unix Subject: Re: Can anyone explain? Message-ID: <1209@hcrvx1.UUCP> Date: Wed, 31-Jul-85 09:16:28 EDT Article-I.D.: hcrvx1.1209 Posted: Wed Jul 31 09:16:28 1985 Date-Received: Thu, 1-Aug-85 02:09:58 EDT Organization: Human Computing Resources, Toronto Lines: 20 >> : 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. If your version of unix has shell functions, you could try something along these lines: cpd() { cp $1 $2/$1 ; cd $2 ; } This defines cpd as a shell function which executes the commands listed *within the current shell*, rather than in a subshell. This is documented in SH(1) (page 2 in the System 5 documentation). Don McKillican @ Human Computing Resources Ltd. {ihnp4,decvax,utzoo,watmath}!hcr!hcrvx1!don