View Full Version : KSH on Mac OS X
andrewmallin
03-05-2003, 07:38 PM
Hi
I am currently trying to configure the korn shell for my OS X box.
I downloaded it from:
http://www.research.att.com/~gsf/download/tgz/ksh.2002-09-22.darwin.ppc.gz
Then unzipped the .gz file, renamed the file from "ksh.2002-09-22.darwin.ppc" to "ksh" and copied to my /bin directory.
Then I changed the permissions for the file so that it is executable:
sudo chmod 555 ksh
I've still not worked out how to make ksh use .kshrc files yet though.
I set my default login shell to ksh and added ksh to /etc/shells, however, I still can't work out how to get it to us my .kshrc file....I believe that I can also utilize .klogin files too...
Any ideas?
ksh uses the more general .profile by default; what I do is (in .profile):
case "$0" in
-sh )
;;
-ksh )
export ENV=${HOME}/.kshrc
;;
esac
The ENV variable will tell ksh to also use your .kshrc. And doing it this way keeps your .profile usable by ksh and sh (and bash), while centralizing ksh-specific stuff in .kshrc.
andrewmallin
03-06-2003, 01:55 PM
Thanks for the tip on this...this code in my own .profile does indeed work.
One thing I do have a problem with is I keep getting;
"en_US: unknown locale"
Now in my .tcshrc file, I got around this problem when switching to ksh by adding the line:
"setenv LANG"
However, this does not seem to work in my .kshrc file. I am assuming that I need to add something like:
set $LANG
?
Do you know the correct syntax
Thanks again
mervTormel
03-06-2003, 02:09 PM
environment variables in the sh family of shells:
$ export LANG=foo
# or, more portable
$ LANG=foo; export LANG
# grep env variables
$ env | grep LANG
LANG=foo
# display a variable
$ echo $LANG
foo
# you'll want to:
LANG=''; export LANG
# in your ksh startup script to emulate your tcsh setup
andrewmallin
03-06-2003, 02:36 PM
Hi
thanks again for the tip...however entering:
LANG=''; export LANG
Into my .kshrc or my .profile does not get rid of
en_US: unknown local
Eventhough when I display my "env"
$ env
_=/usr/bin/env
ENV=/Users/andy/.kshrc
HOME=/Users/andy
LANG=
LOGNAME=andy
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/Users/andy/bin:/usr/bin:usr/local/bin
SHELL=/bin/ksh
TERM=vt100
TERMCAP=???@
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=81
USER=andy
__CF_USER_TEXT_ENCODING=0x1F5:0:0
Have I done something wrong here?
Thanks
That's odd; I have LANG set in my environment (to en_US), but don't run into that error unless running some (if I recall) GTK+-based apps. Of course, the ksh I run is
ls -l /bin/ksh
lrwxr-xr-x 1 root wheel 3 Nov 12 13:37 /bin/ksh@ -> zsh
so I'm using zsh's ksh-emulation capability.
mervTormel
03-06-2003, 03:44 PM
hmm, do you, indeed, have the locale files?
$ ls -l /usr/share/locale/en_US{,.iso*}
lrwxr-xr-x 1 root wheel 15 Sep 25 09:20 /usr/share/locale/en_US -> en_US.ISO8859-1
/usr/share/locale/en_US.ISO8859-1:
total 8
lrwxr-xr-x 1 root wheel 27 Jul 27 2002 LC_CTYPE -> ../la_LN.ISO8859-1/LC_CTYPE
/usr/share/locale/en_US.ISO8859-15:
total 8
lrwxr-xr-x 1 root wheel 28 Jul 27 2002 LC_CTYPE -> ../la_LN.ISO8859-15/LC_CTYPE
Good call; those locale files are part of the BSD package, so perhaps that isn't installed?
andrewmallin
03-16-2003, 03:50 AM
I have now resorted to using PDKSH on my Mac...and the copy I downloaded includes a man page....
curl -O ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14.tar.gz
gnutar -xzf pdksh-5.2.14.tar.gz
cd pdksh-5.2.14
curl -O ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14-patches.1
curl -O ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14-patches.2
patch < pdksh-5.2.14-patches.1
patch < pdksh-5.2.14-patches.2
./configure --prefix=/opt
make
make install
cd ..
rm -rf pdksh-5.2.14
Works a treat and no more locale errors...
Thanks
gatorparrots
03-16-2003, 05:50 AM
fink install pdksh
also works.
andrewmallin
03-16-2003, 11:28 AM
Since I started using Virex 7.2 I've stopped using fink....
See http://fink.sourceforge.net/
The Virex 7.2 package, currently being distributed free to all .Mac members, has a serious conflict with Fink. Fink users should not install Virex 7.2 under any circumstances. Installing it after Fink is installed will damage your Fink installation; installing it prior to Fink will make it impossible to install Fink without damaging Virex.
As far as I am aware this has not been fixed...
But thanks anyway...
A
gatorparrots
03-16-2003, 01:19 PM
*double-post*
Board glitch?
gatorparrots
03-16-2003, 01:35 PM
Given the choice, I would rather have fink's functionality over Virex's. But that's a matter of personal preference.
One important step was left out by the author above in the pdksh installation instructions: adding ksh to the /etc/shells file. Here are ammended directions (installing to the /usr/local tree rather than the /opt tree):
ksh
If you want to try ksh on OS X, you can install pdksh (a korn shell clone) like so:
curl -O ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14.tar.gz
gnutar -xzf pdksh-5.2.14.tar.gz
cd pdksh-5.2.14
curl -O ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14-patches.1
curl -O ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14-patches.2
patch < pdksh-5.2.14-patches.1
patch < pdksh-5.2.14-patches.2
./configure --prefix=/usr/local
make
sudo -s
make install
echo "/usr/local/bin/ksh" >> /etc/shells
exit
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.