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

Jeremy Mates jmates at sial.org
Thu Jan 23 23:15:51 CST 2003


* Brian Hatch <spug at ifokr.org>
> Works fine for me with PD KSH 5.2.14 99/07/13.2

Interesting.

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'
$ mkdir a b
$ cd nosuchdir
ls: nosuchdir: No such file or directory

Error from ls, not cd.  Funny.  Okay, I can live with that.

$ cd a
$ cd ../
jmates

Uh oh, that should have been "a b", not my home directory.

$ cd b
$ cd ../a
ls: ../a: No such file or directory
$ pwd
/home/jmates

Does too exist, and I'm in $HOME instead of $HOME/b.

$ cd /tmp
ssh-AbH31365
$ cd -
ls: -: No such file or directory

Hey!  I like using -!

$ pwd
/home/jmates
$ ls
a b
$ cd a
$ pwd
/home/jmates

Nothing listed, and I am still in $HOME.  Close enough to "wonky" to
deserver the "strange and unexpected" label.

But wait, you say!

 .. It's OpenBSD!
    .. On a Sun Ultra Sparc!
        .. Running pdksh!
             .. in an Educational Institute!

A few blocks away is a production FreeBSD box, unaffiliated with any
Educational Institutes.  FreeBSD has a nifty ports system containing
both pdksh and ksh.  Let's install those, and see how they fare.

$ uname -a
FreeBSD darkness.sial.org 4.7-STABLE FreeBSD 4.7-STABLE #2: Sat Nov 16 10:08:05 PST 2002     root at darkness.sial.org:/usr/obj/usr/src/sys/SIAL  i386
$ echo $KSH_VERSION
@(#)PD KSH v5.2.14.2 99/07/13.2
$ alias cd='\cd "$@" && ls'
$ mkdir a b
$ cd a
$ pwd
/sial/home/jmates

Okay, it doesn't look like an OpenBSD thing: perhaps pdksh is to blame?
Let's try ksh93.

$ echo $KSH_VERSION

$ grep VERSION /usr/ports/shells/ksh93/Makefile 
PORTVERSION=    ${VERSION:S/-//g}
VERSION=        2002-12-21
DISTNAME=       ${PORTNAME}-${VERSION}
DISTFILES=      INIT.${VERSION}.tgz ast-ksh.${VERSION}.tgz
$ alias cd='\cd "$@" && ls'
$ cd a
$ pwd
/sial/home/jmates

Nope, same as pdksh.

Systrace of pdksh on OpenBSD shows ls getting called with the argument,
which might be an interesting line of research into shell oddities.  Or
maybe *ksh and *BSD are at odds?  Who knows...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030123/dc2ee150/attachment.bin


More information about the spug-list mailing list