Switched to Bash and Comparison of Shells
Dan D Niles
dan at more.net
Thu Jun 10 17:19:56 UTC 2010
I had been using csh/tcsh for 20 years and I just switched to bash. The
recent discussion about the differences between the shells prompted me
to take another look at bash. I thought I'd share my perception of the
differences between tcsh and bash.
The big thing tcsh is lacking, and the reason I switched, is the lack of
sensible redirection (as some call it). Specifically, not being able to
do 'command 2>/dev/null >/somefile' is why I switched.
The which command functions differently between bash and tcsh. For
example, I have ls aliased to do color output and add some other options
that I like. With tcsh, 'which ls' returns
"ls: aliased to \ls -GFB"; with bash it returns
"/bin/ls". The tcsh behavior tells you what will be executed when you
run ls. The bash behavior can be achieved in tcsh with 'which \ls', so
I think I like the tcsh behavior better. I could probably write a
function in bash that emulates tcsh's builtin which command.
The alias mechanism in bash lacks the ability to do parameter
substitutions like tcsh can. You can achieve the same thing with bash
functions. The disadvantage of this is it doesn't show up in the
aliases list. I worked around this by adding aliases for the functions
too (because of the which behavior). The advantage of using bash's
functions is you can do more complex things.
With bash-completions installed, the two shells both do completions
well. Bash lacks the "enhance" mode of tcsh that "considers periods,
hyphens and underscores (‘.’, ‘-’ and ‘_’) to be word separators and
hyphens and underscores to be equivalent." Both can do case insensitive
Bash completions do remote file completion, a feature I longed for in
tcsh. There are some bugs in the bash-completions code, mostly due to
its age. For example, the _rsync function still has the default shell
as rsh and remote file completion does not work.
I think tcsh completions are a little easier to set up, but you can do
more with bash completions.
Those are the big differences that I've noticed so far. All in all, the
transition has been fairly easy.
I hope someone will find my observations useful.
More information about the freebsd-questions