Article View: comp.bugs.sys5
Article #93ksh bug on function aliasing
From: Oin
Date: Mon, 04 Sep 1989 10:58
Date: Mon, 04 Sep 1989 10:58
72 lines
2284 bytes
2284 bytes
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
Technical Details
Message-ID:
<776@tuminfo1.lan.informatik.tu-muenchen.dbp.de>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!unido!ztivax!tumuc!lan!schmaussShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!unido!ztivax!tumuc!lan!schmauss From: schmauss@lan.informatik.tu-muenchen.dbp.de (Oin) Newsgroups: comp.bugs.sys5,comp.unix.wizards Subject: ksh bug on function aliasing Keywords: ksh,alias,function,shell builtin Message-ID: <776@tuminfo1.lan.informatik.tu-muenchen.dbp.de> Date: 4 Sep 89 10:58:23 GMT Sender: news@lan.informatik.tu-muenchen.dbp.de Reply-To: schmauss@lan.informatik.tu-muenchen.dbp.de (Oin) Followup-To: comp.bugs.sys5 Organization: Inst. fuer Informatik, TU Muenchen, W. Germany Lines: 72