Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!danews!lvc From: lvc@danews.UUCP Newsgroups: comp.unix.questions Subject: Re: Korn Shell (alias for 'cd') Message-ID: <473@danews.ATT.COM> Date: Mon, 30-Mar-87 19:19:56 EST Article-I.D.: danews.473 Posted: Mon Mar 30 19:19:56 1987 Date-Received: Wed, 1-Apr-87 02:04:07 EST References: <580@csun.UUCP> <2295@tektools.TEK.COM> <350@houxa.UUCP> Organization: AT&T Medical Information Systems, Columbus, Oh Lines: 37 Keywords: Korn shell ksh aliases parameters oops Summary: yet another ksh cd function In article <350@houxa.UUCP>, grs@houxa.UUCP (G.SILLS) writes: > The preferred way to do this is to create a function which performs the > change directory, and then alias cd to that function. For example: > > alias cd=chdir > chdir() > { > cd $1 > PS1="$PWD >" > } > > > or whatever. > > Glenn Sills > BTL Merrimack Valley > !houxa!grs This is a somewhat better PS1/alias/function triple: PS1='$PWD >' # use single quotes alias cd=chdir chdir() { "cd" $* } The "s around the cd in chdir are *needed to prevent alias expansion* but still allows execution of cd. The $* is used instead of $1 because ksh cd can accept two arguments. The definition of PS1 can be done once in single quotes. It will be evaluated *every time* it is printed (so will the ENV parameter). -- Larry Cipriani, AT&T Network Systems, Columbus OH, (614) 860-4999