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

Michael R. Wolf MichaelRunningWolf at att.net
Fri Jan 24 15:23:06 CST 2003

Brian Hatch <spug at ifokr.org> writes:

> Jeremy Mates <jmates at sial.org> writes:
> > 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.


Sorry if I appeared to doubt you.  I was looking for the kinds of
symptoms that you did post below.

> Jeremy Mates <jmates at sial.org> continues:
> > $ 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'


Thanks for disproving my untested code.


> 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.


After consulting my dogeared Bolsky/Korn book ("The Kornshell Command
and Programming Language" - 1989 version, documenting the 11/16/88
version of ksh), I realized that aliases are a simple textual
substitution, as you illustrated.  Functional call semantics require a
call to a real function (or builtin, or executable).

Sorry for leading folks down a dead end.  I tried to put in my $0.02
on something that I don't use -- aliases -- and failed miserably.
Over the years, I try to use 'em, and keep finding reasons not to.
I've now got yet another reason to pump up ~/bin with scripts instead
of mucking ~/.profile or my $ENV file.

Michael R. Wolf
    All mammals learn by playing!
        MichaelRunningWolf at att.net

More information about the spug-list mailing list