Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ucla-cs!sdcrdcf!psivax!csun!aeusesef From: aeusesef@csun.UUCP Newsgroups: comp.unix.questions Subject: Re: Korn Shell (alias for 'cd') Message-ID: <598@csun.UUCP> Date: Wed, 1-Apr-87 12:31:27 EST Article-I.D.: csun.598 Posted: Wed Apr 1 12:31:27 1987 Date-Received: Sat, 4-Apr-87 12:09:50 EST References: <580@csun.UUCP> <2295@tektools.TEK.COM> <350@houxa.UUCP> <1341@uvacs.CS.VIRGINIA.EDU> Reply-To: aeusesef@csun.UUCP (Sean Eric Fagan) Organization: California State University, Northridge Lines: 58 Keywords: Korn shell ksh aliases parameters oops In article <1341@uvacs.CS.VIRGINIA.EDU> rwl@uvacs.CS.VIRGINIA.EDU (Ray Lubinsky) writes: $$ alias cd=chdir $$ chdir() $$ { $$ cd $1 $$ PS1="$PWD >" $$ } $ $Actually, you have to quote the cd within chdir to retain it's orginal meaning. $Otherwise you've set up a recursive call to the alias cd: $ $ alias cd=chdir $ function chdir $ { $ 'cd' $1 $ PS1="$PWD >" $ } $ $I discover this while trying to modify cd to fit in with my pushd and popd $functions. $ $-- $| Ray Lubinsky Department of Computer Science, University of Virginia | Ok, finally my reply (being the one who started this whole mess). The original problem was that I wanted to do something like this (this is for C shell): alias cd 'chdir !$ ; dirs' (please note that I did *not* want to change the prompt) in Korn shell. I tried alias cd='chdir !$ ; print - $PWD', but that didn't work, so I changed the !$ to $*. Still no go. That was when I posted my original article (got it somewhere around here...). Just after I posted it, it was suggested to me that I try alias cd=cd1 funtion cd1 { chdir $1; print - $PWD } That worked, but I wanted to see if there were any better way of doing it. So far, noone has suggested any. (Are you reading this, Bell Labs?) Anyway, that is the way to do it, and you cannot use the example above since chdir is a Korn shell built-in. Apparanlty, Korn shell searches aliases, then built-ins, then functions, then uses PATH. If, however, you use a different name, it will work. I tried to reply to everyone who sent me mail, but I am not sure if I did. To those whom I missed, and also those who posted replies, thanks for the try, its not your fault C shell is superior in only one aspect... ----- Sean Eric Fagan ------\ Computer Center litvax \ Cal State University, Northridge rdlvax \ 18111 Nordhoff St. psivax --> !csun!aeusesef Northridge, CA 91330 hplabs / AGTLSEF@CALSTATE.BITNET ihnp4 / ------/ "I drank what?!" -- Socrates | My opinions *are* facts.