ksh bug on function aliasing

scott.thompson sft at cbnewsc.ATT.COM
Thu Sep 7 03:19:51 AEST 1989


>From article <776 at tuminfo1.lan.informatik.tu-muenchen.dbp.de>, by schmauss at lan.informatik.tu-muenchen.dbp.de (Oin):
> Here is a bug I've found in ksh @(#)Version 06/03/86.
> I declared a function chdir() for the shell builtin cd and
> aliased cd to be chdir() ( see script below for details ).
> Now have a look at the following two different behaviours of ksh:
> 
 ... example deleted ...
> 

This is not a bug, as a matter of fact it is documented; aliases are
expanded at the time of function DEFINITION.

By the way ksh will expand the $PWD environment variable in PS1
automagically, no need for the function.  I believe this is supported in
the version you are using, just postpone the evaluation of the
appropriate variable, namely $PWD:

			PS1="\${PWD} ! \$ "
			PS2="\${PWD} >>> "

Also, you don't need to unalias cd within the chdir function, just place
it in single quotes.  ie:

			'cd' $*
-- 
  Scott Thompson (IH 6W-207), AT&T Bell Labs, Naperville, Il. 60566

       VOICE: (312)-979-2237     UUCP: ...!att!ihlpa!sft



More information about the Comp.bugs.sys5 mailing list