SPUG:Re: aliases, -> Korn Shell vs. PD-ksh

Brian Hatch spug at ifokr.org
Thu Jan 23 23:32:45 CST 2003



> My test results, since folks appear to doubt the veracity of my claim
> that ksh goes "wonky" with the alias definition in question.  Our first
> contestant is a just-recently-installed Sun Ultra Sparc running OpenBSD
> 3.2-stable as of 2003-01-21.
> 
> $ uname -a
> OpenBSD akira.gs.washington.edu 3.2 GENERIC#0 sparc64
> $ echo $KSH_VERSION
> @(#)PD KSH v5.2.14 99/07/13.2
> $ alias cd='\cd "$@" && ls'

Try this alias on bash and you'll get the same results.
Why?  This alias doesn't work.  When you type

	bash_or_ksh$ cd /tmp

it expands to

	cd "" && ls /tmp

Aliases do not take arguments.  Nothing is in $@.  The
reason you never cd anywhere and are always in your home
dir is because you are explicitly saying to go there
with the cd sans arguments.  But you list the 'correct'
dir because your commandline args are appended to the
alias commands.

Proof:

	bash_or_ksh$ alias cd='echo "Arguments $@" && echo "ls"'
	bash_or_ksh$ cd /tmp
	Arguments
	ls /tmp



If you want $@, you need to use a function.

I'm going to bed now.  I'll defend ksh again when I wake up
if necessary.  ;-)



--
Brian Hatch                  I doubt,
   Systems and                therefore
   Security Engineer          I might be.
http://www.ifokr.org/bri/

Every message PGP signed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030123/2bd7803a/attachment.bin


More information about the spug-list mailing list