[plug] zsh vs bash

Peter Wright pete at cygnus.uwa.edu.au
Sat Feb 10 13:37:04 WST 2001


On Fri, Feb 09, 2001 at 11:24:57AM +0800, Mike Holland wrote:
[ snip ]
>   In fact, why use bash at all, apart from scripting? I graduated from csh
> to zsh long ago, and last I looked, bash was way behind in interactive
> features.

Likewise.

> But looking again at the man page - it seems to have lots of
> 'new' features, like command/filename/variable-completion (with menus),
> emacs key bindings, ... even csh-style history substitution.

I've pretty much assumed for a while now that bash _probably_ does
have most of zsh's more funky features, just that it would probably
require more effort than I'm willing to make to find them. (I find the
bash man page difficult to find things on as well - the zsh man
page(s) are, I think, somewhat better. (note that this is just a
personal opinion, I'm sure there are ample supplies of of decent bash
docos out there)).

To refer to the (actually very good) interview with David Korn on /.
again, go read it if you haven't. I really did like his perspective on
shells as far as interactive use went. I'd have to agreee that on the
interactive front, there's probably very little difference in
functionality between zsh/bash/tcsh. It's just that among that "little
functionality" that _is_ different there can sometimes be a killer feature
for a particular user.

I don't use any shell for scripting purposes, I use perl (trying to
use python as well now). So Mr Korn's emphasis on Korn being the most
powerful shell for scripting/programming purposes just didn't matter
to me. I know it does to a lot of people though.

I am forced occasionally to edit shell scripts - but I get headaches
beyond simple bourne shell scripts. C-shell based scripts I just
don't want to look at, just run them and hope they work and I don't have to
fiddle with them.

Fortunately I've only had to use one csh script in the last few years,
(which was provided with CVS, which I think was intended for converting an
SCCS project to CVS format - and it worked perfectly, woohoo).

>    I dont see an 'auto_pushd' for example, but I guess an alias would do
> the job. (So it remembers past directories, and you can go back.)

This is the one thing that pisses me off intensely about bash -
I would love to be able to do a 'popd' on the far too frequent
occasions when I have to use (someone else's :) bash prompt.

If anyone does know how to emulate this behaviour in bash (or if later
versions of bash have it working by default) please let me know.

>    What do PLUG members use?
> Anyone know both well enough to give a verdict?
>   Is zsh obsolete? Or is this a vi/emacs kind of thing?

I don't think zsh/bash would qualify as a vi/emacs type thing, they're
not different enough  (and bash has so many more devotees than zsh
it's not funny). Perhaps a tcsh/bash thing might be a better
comparison.

> Other features I might miss are RPROMPT, chpwd(), PRINT_EXIT_VALUE,
> REPORTTIME .

I used RPROMPT for a while when I first used zsh (right prompt, for
those not in the know - a prompt on the right hand side of your
display, usually used along with a left prompt as a way of showing
additional info without taking up space on the left-hand side of the
screen), and eventually decided it was more wank than really useful
(again, just my personal opinion, opposing views welcome :).

The others I don't know, I'll look them up though if you think they're
worth knowing about.

> Mike Holland  <mike at golden.wattle.id.au>

On Fri, Feb 09, 2001 at 12:55:17PM +0800, Christian wrote in response
to Mike:
> I used bash initially just because that was there and after fiddling
> with tcsh for a while decided that bash was far superior for
> interactive use.

I know a number otf tcsh advocates who woud probably dispute that
strongly with you :). However, you're probably right, though I'd still
s/far/mildly/.

However, I don't think I know anyone who would use tcsh for writing
scripts. Mr Christiansen's(?) "Csh Programming Considered Harmful" may
be out of date by now, but not enough to reduce its impact.

> What interactive features does zsh have?  (In
> particular, what does it have that bash doesn't?)

Well, I first started using zsh after seeing this table (which I'm including
in this email for the sake of completeness as I know there are a few people
who read their email offline - sorry it's biggish - but here is the URL I
found it at if you'd prefer):

http://www.rz.go.dlr.de:8081/info/faqs/unix-shells/unix-shell-differences.html
----------------------------------------------------------------------
                                     sh   csh  ksh  bash tcsh zsh  rc   es
Job control                          N    Y    Y    Y    Y    Y    N    N
Aliases                              N    Y    Y    Y    Y    Y    N    N
Shell functions                      Y(1) N    Y    Y    N    Y    Y    Y
"Sensible" Input/Output redirection  Y    N    Y    Y    N    Y    Y    Y
Directory stack                      N    Y    Y    Y    Y    Y    F    F
Command history                      N    Y    Y    Y    Y    Y    L    L
Command line editing                 N    N    Y    Y    Y    Y    L    L
Vi Command line editing              N    N    Y    Y    Y(3) Y    L    L
Emacs Command line editing           N    N    Y    Y    Y    Y    L    L
Rebindable Command line editing      N    N    N    Y    Y    Y    L    L
User name look up                    N    Y    Y    Y    Y    Y    L    L
Login/Logout watching                N    N    N    N    Y    Y    F    F
Filename completion                  N    Y(1) Y    Y    Y    Y    L    L
Username completion                  N    Y(2) Y    Y    Y    Y    L    L
Hostname completion                  N    Y(2) Y    Y    Y    Y    L    L
History completion                   N    N    N    Y    Y    Y    L    L
Fully programmable Completion        N    N    N    N    Y    Y    N    N
Mh Mailbox completion                N    N    N    N(4) N(6) N(6) N    N
Co Processes                         N    N    Y    N    N    Y    N    N
Builtin artithmetic evaluation       N    Y    Y    Y    Y    Y    N    N
Can follow symbolic links invisibly  N    N    Y    Y    Y    Y    N    N
Periodic command execution           N    N    N    N    Y    Y    N    N
Custom Prompt (easily)               N    N    Y    Y    Y    Y    Y    Y
Sun Keyboard Hack                    N    N    N    N    N    Y    N    N
Spelling Correction                  N    N    N    N    Y    Y    N    N
Process Substitution                 N    N    N    Y(2) N    Y    Y    Y
Underlying Syntax                    sh   csh  sh   sh   csh  sh   rc   rc
Freely Available                     N    N    N(5) Y    Y    Y    Y    Y
Checks Mailbox                       N    Y    Y    Y    Y    Y    F    F
Tty Sanity Checking                  N    N    N    N    Y    Y    N    N
Can cope with large argument lists   Y    N    Y    Y    Y    Y    Y    Y
Has non-interactive startup file     N    Y    Y(7) Y(7) Y    Y    N    N
Has non-login startup file           N    Y    Y(7) Y    Y    Y    N    N
Can avoid user startup files         N    Y    N    Y    N    Y    Y    Y
Can specify startup file             N    N    Y    Y    N    N    N    N
Low level command redefinition       N    N    N    N    N    N    N    Y
Has anonymous functions              N    N    N    N    N    N    Y    Y
List Variables                       N    Y    Y    N    Y    Y    Y    Y
Full signal trap handling            Y    N    Y    Y    N    Y    Y    Y
File no clobber ability              N    Y    Y    Y    Y    Y    N    F
Local variables                      N    N    Y    Y    N    Y    Y    Y
Lexically scoped variables           N    N    N    N    N    N    N    Y
Exceptions                           N    N    N    N    N    N    N    Y

Key to the table above.

   Y      Feature can be done using this shell.

   N      Feature is not present in the shell.

   F      Feature can only be done by using the shells function
          mechanism.

   L      The readline library must be linked into the shell to enable
          this Feature.

Notes to the table above

    1. This feature was not in the orginal version, but has since become
       almost standard.
    2. This feature is fairly new and so is often not found on many
       versions of the shell, it is gradually making its way into
       standard distribution.
    3. The Vi emulation of this shell is thought by many to be
       incomplete.
    4. This feature is not standard but unoffical patches exist to
       perform this.
    5. A version called 'pdksh' is freely available, but does not have
       the full functionality of the AT&T version.
    6. This can be done via the shells programmable completion mechanism.
    7. Only by specifing a file via the ENV environment variable.
----------------------------------------------------------------------

I just looked at the table, went "wow, zsh has a lot of 'Y's that tcsh and
bash don't have, I might have to try it." Have used it very happily since then
(I moved straight from tcsh to zsh, I've never used bash as my primary
(s)hell).

BTW, I'm sure the above table is not completely up to date. Things may well
have changed quite a bit.

Have a look at the zsh FAQ for much more specific and up-to-date information
on differences and comparisons between it and bash/tcsh - mainly oriented
towards scripting use rather than interactive use though.

http://sunsite.dk/zsh/FAQ/ 

Well, in my opinion it's a bloody good shell :). Also, from a purely
nationalistic point of view, the primary www.zsh.org site is actually hosted
in Australia - I'm not sure if that implies a significant number of the
primary developers are Australian or anything, but it's interesting to note in
any case.

Hope that the above load of waffle contained something interesting to someone,
somewhere. :)

Pete.
-- 
http://cygnus.uwa.edu.au/~pete/

--
hundred-and-one symptoms of being an internet addict:
226. You sit down at the computer right after dinner and your spouse
     says "See you in the morning."




More information about the plug mailing list