ksh bug on function aliasing
Oin
schmauss at lan.informatik.tu-muenchen.dbp.de
Mon Sep 4 20:58:23 AEST 1989
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:
Situation 1:
declare function
declare alias
call alias
everything's fine...
305 $ chdir ()
>>> {
>>> unalias cd
>>> cd $*
>>> PS1="${PWD} ! \$ "
>>> alias cd=chdir
>>> }
306 $ alias cd=chdir
307 $ cd /tmp
/tmp 308 $ cd /usr/include
/usr/include 309 $ type cd
cd is an alias for chdir
/usr/include 310 $ type chdir
chdir is a function
/usr/include 311 $ typeset -f chdir
function chdir
{
unalias cd
cd $*
PS1="${PWD} ! \$ "
alias cd=chdir
}
Situation 2:
declare alias
declare function
call alias
@#$%%^&*
/usr/include 312 $ chdir ()
>>> {
>>> unalias cd
>>> cd $*
>>> PS1="${PWD} ! \$ "
>>> PS2="${PWD} >>> "
>>> alias cd=chdir
>>> }
/usr/include 313 $ type cd
cd is an alias for chdir
/usr/include 314 $ type chdir
chdir is a function
/usr/include 315 $ typeset -f chdir
function chdir
{
unalias cd
cd $*
PS1="${PWD} ! \$ "
PS2="${PWD} >>> "
alias cd=chdir
}
/usr/include 316 $ cd /
sh: chdir: recursive call
Franz "Oin" Schmausser local: lan.informatik.tu-muenchen.dbp.de
TU Muenchen, Inst. f. Informatik DFN: schmauss@{local}
Arcisstrasse UUCP: schmauss%{local}@unido.uucp
D-8000 Muenchen ARPA/CS: schmauss%{local}@relay.cs.net
More information about the Comp.unix.wizards
mailing list