[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: impressions of a new user



On Fri, Aug 15, 2003 at 10:56:38AM -0500, Charles J. Fisher wrote:
> Things I don't like:
> ...
> (pd)ksh is not configured very well; everything is configured for (t)csh.
> There was no /etc/profile (if I remember correctly).

This is simply not true.  There is a file /etc/ksh.kshrc.  It clearly
states at the top

# DESCRIPTION:
#       Each invocation of /bin/ksh processes the file pointed
#       to by $ENV (usually $HOME/.kshrc).
#       This file is intended as a global .kshrc file for the
#       Korn shell.  A user's $HOME/.kshrc file simply requires
#       the line:
#               . /etc/ksh.kshrc
#       at or near the start to pick up the defaults in this
#       file which can then be overridden as desired.

It's a fairly decent default configuration once you set ENV in your
.profile and invoke /etc/ksh.kshrc from your .kshrc as described above.

I really like OpenBSDs choice of ksh as a default sh shell.  It's small
compared to bash, and, frankly, I still have scripts that fail under
bash on RH9 and work with no trouble in ksh.  Here's a contrived example
made from a much more complex script stripping it to a bare minimum, and
changing "awk" line to a simple "cat" and "rsync" line to "ls".
I also simplified a list to demonstrate the issue.

A file list.txt contains
====== cut =======
.X{modmap,defaults}
====== cut =======

A file buginbash.sh contains:
====== cut =======
#!/bin/bash
CMD="cat list.txt"
ls $(${CMD})
====== cut =======

When run in my home directory it gives:
$ ./buginbash.sh 
ls: .X{modmap,defaults}: No such file or directory

When "#!/bin/bash" is changed to "#!/bin/ksh" and run again the result
is:

$ ./buginbash.sh
.Xdefaults  .Xmodmap

as it should be.

> It is sad to see OpenBSD and Apple using such a discredited shell. csh
> has profound problems as a scripting shell, and people should use the
> same shell for scripting that they use interactively.

Again, not true.  Why should I use the same shell for scripting and
interactive work?  I always use sh for scripting.  But I see no reason
not to use tcsh as an interactive shell.  Recommended reading:

http://ezine.daemonnews.org/200112/csh_tcsh_part1.html

tcsh is an excellent interactive shell.  I use it on RH9 at work.
I use ksh on my OpenBSD machines because I do not see the need to
install any shell from ports, when ksh can already do all I need.

-- 
Zvezdan Petkovic <zvezdan@cs.wm.edu>
http://www.cs.wm.edu/~zvezdan/