Subject: A shell gotcha
To: None <current-users@NetBSD.ORG>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: current-users
Date: 04/15/1995 13:50:26
This may not really be a new problem, but it only struck me last night.
It also isn't likely NetBSD specific, but that's where I found it.  :-)
I might be the last person in the world to have figured it out, but if
not I thought I'd save someone else the trouble.

Last night, I installed the latest copy of pdksh (my favorite shell),
and all hell broke loose; my login script was causing complaints about
"let: arith: bad syntax (top=0)" and many other fiendish complaints,
including a gripe about /usr/bin/cpp not working!  After much hair
tearing and searching for latest-and-greatests of several alternative
shells, I finally discovered that /bin/sh "now" recognizes the ENV
environment variable, and it was choking trying to understand my
ksh-specific .aliases file.  (Of course, /bin/sh has at LEAST
understood ENV since March 4, when I last installed binaries, and
probably has done so for a LONG time.  I don't know *why* this only
struck now.)

The obvious solution was to figure out how to arrange for the .aliases
file not to make /bin/sh choke.  After many false starts, I discovered
that pdksh defines an environment variable "KSH_VERSION", which makes
a handy test for which shell is running the script.  (The ksh syntax
has to be kept out of the file, so I "dot" the ksh specific stuff.)
It turns out that zsh (what I'd been using for a while) also defines a
version variable ("ZSH_VERSION"), making a three-way split easy to
arrange.  For csh fans, tcsh defines a "version" variable.

I hope this saves someone some time and annoyance.