home *** CD-ROM | disk | FTP | other *** search
/ Danny Amor's Online Library / Danny Amor's Online Library - Volume 1.iso / html / faqs / faq / unix-faq / shell.shell-difference < prev    next >
Encoding:
Text File  |  1995-07-25  |  18.3 KB  |  358 lines

  1. Subject: UNIX shell differences and how to change your shell (Monthly Posting)
  2. Newsgroups: comp.unix.shell,comp.unix.questions,news.answers,comp.answers
  3. From: Brian Blackmore <bnb@gryphon.demon.co.uk>
  4. Date: 30 Oct 1994 13:39:32 -0000
  5.  
  6. Archive-name: unix-faq/shell/shell-differences
  7. Version: 1.08
  8.  
  9.  
  10.    The following article answers the frequently asked questions, what
  11.    UNIX shells are available, what are the differences between them and
  12.    how do you change your interactive shell.
  13.    
  14. Contents
  15.  
  16.      * Modifications since last issue
  17.      * Why change your shell
  18.      * The history of unix shells
  19.      * Deciding on a shell
  20.      * Shell features (table)
  21.      * How to change your shell
  22.      * A warning about changing your shell
  23.      * Further information
  24.      * Copyright and Disclaimer
  25.        
  26. Modifications since last issue
  27.  
  28.      * Added a short paragraph about es to the shell history section, and
  29.        added es into the shell table. More information would be
  30.        appreciated especially on the history side with reguards to this.
  31.      * Added several new columns to the shell function table to reflect
  32.        the abilities of es and rc better.
  33.      * Added information about where to get tcsh by ftp, and information
  34.        about CCsh a bourne shell compiler, to the further information
  35.        section.
  36.        
  37. Why change your shell
  38.  
  39.    The UNIX shell is most people's main access to the UNIX operating
  40.    system and as such any improvement to it can result in considerably
  41.    more effective use of the system, and may even allow you to do things
  42.    you couldn't do before. The primary improvement most of the new
  43.    generation shells give you is increased speed. They require fewer key
  44.    strokes to get the same results due to their completion features, they
  45.    give you more information (e.g. showing your directory in your prompt,
  46.    showing which files it would complete) and they cover some of the more
  47.    annoying features of UNIX, such as not going back up symbolic links to
  48.    directories.
  49.    
  50. A brief history of UNIX shells
  51.  
  52.    In the near beginning there was the Bourne shell /bin/sh (written by
  53.    S. R. Bourne). It had (and still does) a very strong powerful
  54.    syntactical language built into it, with all the features that are
  55.    commonly considered to produce structured programs; it has
  56.    particularly strong provisions for controlling input and output and in
  57.    its expression matching facilities. But no matter how strong its input
  58.    language is, it had one major drawback; it made nearly no concessions
  59.    to the interactive user (the only real concession being the use of
  60.    shell functions and these were only added later) and so there was a
  61.    gap for something better.
  62.    
  63.    Along came the people from UCB and the C-shell /bin/csh was born. Into
  64.    this shell they put several concepts which were new, (the majority of
  65.    these being job control and aliasing) and managed to produce a shell
  66.    that was much better for interactive use. But as well as improving the
  67.    shell for interactive use they also threw out the baby with the bath
  68.    water and went for a different input language.
  69.    
  70.    The theory behind the change was fairly good, the new input language
  71.    was to resemble C, the language in which UNIX itself was written, but
  72.    they made a complete mess of implementing it. Out went the good
  73.    control of input and output and in came the bugs. The new shell was
  74.    simply too buggy to produce robust shell scripts and so everybody
  75.    stayed with the Bourne shell for that, but it was considerably better
  76.    for interactive use so changed to the C shell, this resulted in the
  77.    stupid situation where people use a different shell for interactive
  78.    work than for non-interactive, a situation which a large number of
  79.    people still find themselves in today.
  80.    
  81.    After csh was let loose on an unsuspecting world various people
  82.    decided that the bugs really should get fixed, and while they where at
  83.    it they might as well add some extra features. In came command line
  84.    editing, TENEX-style completion and several other features. Out went
  85.    most of the bugs, but did the various UNIX operating system
  86.    manufacturers start shipping tcsh instead of csh? No, most of them
  87.    stuck with the standard C-Shell, adding non-standard features as they
  88.    went along.
  89.    
  90.    Eventually David Korn from AT&T had the bright idea to sort out this
  91.    mess and the Korn shell /bin/ksh made its appearance. This quite
  92.    sensibly junked the C shells language and reverted back to the bourne
  93.    shell language, but it also added in the many features that made the C
  94.    shell good for interactive work (you could say it was the best of both
  95.    worlds), on top of this, it also added a some features from other
  96.    operating. The Korn shell became part of System V but had one major
  97.    problem; unlike the rest of the UNIX shells it wasn't free, you had to
  98.    pay AT&T for it.
  99.    
  100.    It was at about this time that the first attempts to standardize UNIX
  101.    started in the form of the POSIX standard. POSIX specified more or
  102.    less the System V Bourne Shell (by this time the BSD and System V
  103.    versions had got slightly different). Later the standard is upgraded,
  104.    and somehow the new standard managed to look very much like ksh.
  105.    
  106.    Also at about this time the GNU project was underway and they decided
  107.    that they needed a free shell, they also decided that they wanted to
  108.    make this new shell POSIX compatible, thus bash (the Bourne again
  109.    shell) was born. Like the Korn shell bash was based upon the Bourne
  110.    shells language and like the Korn shell, it also pinched features from
  111.    the C shell and other operating systems (in my opinion it put them
  112.    together better; guess which shell I use), but unlike the Korn shell
  113.    it is free. Bash was quickly adopted for LINUX (where it can be
  114.    configured to perform just like the Bourne shell), and is the most
  115.    popular of the free new generation shells.
  116.    
  117.    Meanwhile Tom Duff faced with the problem of porting the Bourne shell
  118.    to Plan 9, revolts and writes rc instead, he publishes a paper on it,
  119.    and Byron Rakitzis reimplements it under UNIX. With the benefit of a
  120.    clean start Rc ended up smalled, simpler, more regular and in most
  121.    peoples opinion a much cleaner shell.
  122.    
  123.    The search for the perfect shell still goes on and the latest entry
  124.    into this arena is zsh. Zsh was written by Paul Falstad while he was a
  125.    student a Princeton and suffers from slight case of feeping
  126.    creaturism. It is based roughly on the bourne shell (although there
  127.    are some minor but important differences) and has so many additional
  128.    features that I don't even think the author even knows all of them.
  129.    
  130.    Additionally rc has been enhanced to produced es, this shell adds the
  131.    ability for the user to redefine low level functions.
  132.    
  133. Deciding on a shell
  134.  
  135.    Which of the many shells you choose depends on many different things,
  136.    here is what I consider to be the most important, you may think
  137.    differently.
  138.    
  139.    How much time do I have to learn a new shell?
  140.           There is no point in using a shell with a different syntax, or
  141.           a completly different alias system if you havn't the time to
  142.           learn it. If you have the time and are presently using csh or
  143.           tcsh it is worth considering a switch to a Bourne shell
  144.           variant.
  145.           
  146.    What do I wish to be able to do with my new shell?
  147.           The main reason for switching shells is to gain extra
  148.           functionality; its vital you know what you are gaining from the
  149.           switch.
  150.           
  151.    Do I have to be able to switch back to a different shell?
  152.           If you may have to switch back to a standard shell, it is
  153.           fairly important you don't become too dependent on extra
  154.           features and so can't use an older shell.
  155.           
  156.    How much extra load can the system cope with?
  157.           The more advanced shells tend to take up extra CPU, since they
  158.           work in cbreak mode; if you are on an overloaded machine they
  159.           should probably be avoided; this can also cause problems with
  160.           an overloaded network. This only really applies to very old
  161.           systems nowadays.
  162.           
  163.    What support is given for my new shell?
  164.           If your new shell is not supported make sure you have someone
  165.           you can ask if you encounter problems or that you have the time
  166.           to sort them out yourself.
  167.           
  168.    What shell am I using already?
  169.           Switching between certain shells of the same syntax is alot
  170.           easier than switching between shells of a different syntax. So
  171.           if you havn't much time a simple upgrade (eg csh to tcsh) may
  172.           be a good idea.
  173.           
  174.    Can I afford any minor bugs?
  175.           Like most software all shells have some bugs in them
  176.           (especially csh), can you afford the problems that may occur
  177.           because of them.
  178.           
  179.    Do you need to be able to use more than one shell?
  180.           If you use more than system then you may need to know more than
  181.           one shell at the same time. How different are these two shells
  182.           and can you manage the differences between them.
  183.           
  184. Shell features
  185.  
  186.    This table below lists most features that I think would make you
  187.    choose one shell over another. It is not intended to be a definitive
  188.    list and does not include every single possible feature for every
  189.    single possible shell. A feature is only considered to be in a shell
  190.    if in the version that comes with the operating system, or if it is
  191.    available as compiled directly from the standard distribution. In
  192.    particular the C shell specified below is that available on SUNOS 4.*,
  193.    a considerable number of vendors now ship either tcsh or their own
  194.    enhanced C shell instead (they don't always make it obvious that they
  195.    are shipping tcsh.
  196.  
  197.                                      sh   csh  ksh  bash tcsh zsh  rc   es
  198. Job control                          N    Y    Y    Y    Y    Y    N    N
  199. Aliases                              N    Y    Y    Y    Y    Y    N    N
  200. Shell functions                      Y(1) N    Y    Y    N    Y    Y    Y
  201. "Sensible" Input/Output redirection  Y    N    Y    Y    N    Y    Y    Y
  202. Directory stack                      N    Y    Y    Y    Y    Y    F    F
  203. Command history                      N    Y    Y    Y    Y    Y    L    L
  204. Command line editing                 N    N    Y    Y    Y    Y    L    L
  205. Vi Command line editing              N    N    Y    Y    Y(3) Y    L    L
  206. Emacs Command line editing           N    N    Y    Y    Y    Y    L    L
  207. Rebindable Command line editing      N    N    N    Y    Y    Y    L    L
  208. User name look up                    N    Y    Y    Y    Y    Y    L    L
  209. Login/Logout watching                N    N    N    N    Y    Y    F    F
  210. Filename completion                  N    Y(1) Y    Y    Y    Y    L    L
  211. Username completion                  N    Y(2) Y    Y    Y    Y    L    L
  212. Hostname completion                  N    Y(2) Y    Y    Y    Y    L    L
  213. History completion                   N    N    N    Y    Y    Y    L    L
  214. Fully programmable Completion        N    N    N    N    Y    Y    N    N
  215. Mh Mailbox completion                N    N    N    N(4) N(6) N(6) N    N
  216. Co Processes                         N    N    Y    N    N    Y    N    N
  217. Builtin artithmetic evaluation       N    Y    Y    Y    Y    Y    N    N
  218. Can follow symbolic links            N    N    Y    Y    Y    Y    N    N
  219. Periodic command execution           N    N    N    N    Y    Y    N    N
  220. Custom Prompt (easily)               N    N    Y    Y    Y    Y    Y    Y
  221. Sun Keyboard Hack                    N    N    N    N    N    Y    N    N
  222. Spelling Correction                  N    N    N    N    Y    Y    N    N
  223. Process Substitution                 N    N    N    Y(2) N    Y    Y    Y
  224. Underlying Syntax                    sh   csh  sh   sh   csh  sh   rc   rc
  225. Freely Available                     N    N    N(5) Y    Y    Y    Y    Y
  226. Checks Mailbox                       N    Y    Y    Y    Y    Y    F    F
  227. Tty Sanity Checking                  N    N    N    N    Y    Y    N    N
  228. Can cope with large argument lists   Y    N    Y    Y    Y    Y    Y    Y
  229. Has non-interactive startup file     N    Y    Y(7) Y(7) Y    Y    N    N
  230. Has non-login startup file           N    Y    Y(7) Y    Y    Y    N    N
  231. Can avoid user startup files         N    Y    N    Y    N    Y    Y    Y
  232. Can specify startup file             N    N    Y    Y    N    N    N    N
  233. Low level command redefinition       N    N    N    N    N    N    N    Y
  234. Has Lambda function                  N    N    N    N    N    N    Y    Y
  235. List Variables                       N    Y    Y    N    Y    Y    Y    Y
  236. Full signal trap handling            Y    N    Y    Y    N    Y    Y    Y
  237. File no clobber ability              N    Y    Y    Y    Y    Y    N    F
  238.  
  239. Key to the table above.
  240.  
  241.    Y      Feature can not be done using this shell.
  242.           
  243.    N      Feature is not present in the shell.
  244.           
  245.    F      Feature can only be done by using the shells function
  246.           mechanism.
  247.           
  248.    L      The readline library must be linked into the shell to enable
  249.           this Feature.
  250.           
  251. Notes to the table above
  252.  
  253.     1. This feature was not in the orginal version, but has since become
  254.        almost standard.
  255.     2. This feature is fairly new and so is often not found on many
  256.        versions of the shell, it is gradually making its way into
  257.        standard distribution.
  258.     3. The Vi emulation of this shell is thought by many to be
  259.        incomplete.
  260.     4. This feature is not standard but unoffical patches exist to
  261.        perform this.
  262.     5. A version called 'pdksh' is freely available, but does not have
  263.        the full functionality of the AT&T version.
  264.     6. This can be done via the shells programmable completion mechanism.
  265.     7. Only by specifing a file via the ENV environment variable.
  266.        
  267. How to change your shell
  268.  
  269.    If you ever look at a UNIX manual page it will say that to change your
  270.    shell use chsh or passwd -s; unfortunately it often isn't as simple as
  271.    this, since it requires that your new shell is recognized as a valid
  272.    shell by the system and at present many systems do not recognize the
  273.    newer shells (the normal selection is, /bin/sh, /bin/csh and possibly
  274.    /bin/ksh). You are thus left with having to do some sort of fudge,
  275.    changing your effective login shell without changing your official
  276.    entry in /etc/passwd. You may also be left with the problem that there
  277.    isn't a compiled binary on your system , so you will have to get hold
  278.    of the shell's source and compile it yourself (Its generally best to
  279.    ask around to see if anyones done this already, since it isn't that
  280.    easy). Once done you should add in code to your old shells login file
  281.    so that it overlays your official login shell with your new shell
  282.    (remember to add the login flags to the command line, and with
  283.    csh/tcsh ensure that the overlay doesn't happen recursively since they
  284.    both read the same .login file).
  285.    
  286.    The shell can be recognized as a valid shell if the system
  287.    administrator puts it in the file /etc/shells. If this file does not
  288.    exist, it must be created and should contain all valid shells
  289.    (i.e.don't forget the traditional ones in all their forms).
  290.    
  291. WARNING
  292.  
  293.     If you do decide to change your shell you must be very careful - if
  294.    handled wrongly it can be almost impossible to correct, and will
  295.    almost certainly cause you a lot of hassle. Never make a new shell a
  296.    login shell until you have tested its new configuration files
  297.    thoroughly and then tested them once again. It is also important that
  298.    you make a full backup of your previous config files onto a floppy
  299.    disk (or a different host if you have a second account) if you have to
  300.    change any of them (which you will probably have to do if you can't
  301.    change your shell entry in /etc/passwd). You should also note that
  302.    your new shell is probably not supported by your system admin, so if
  303.    you have any problems you will probably have to look elsewhere.
  304.    
  305. Further information
  306.  
  307.    The Bourne shell, the C-Shell and the Korn Shell (if you have it) are
  308.    all distributed as standard with your UNIX operating system,
  309.    information on these should come with your operating system, bug
  310.    reports etc should be sent to your operating system vendor.
  311.    
  312.    A commercial "compiler" (CCsh) is available for the Bourne shell, this
  313.    can provide extra speed on some applications. For more information
  314.    contact Comeau Computing 91-34 120th Street, Richmond Hill, NY, USA
  315.    11418-3214. Email comeau@csanta.attmail.com.
  316.    
  317.    Bash was written and is maintained by the Free Software Foundation,
  318.    the primary source of information for this shell is its manual page.
  319.    Bug reports should be sent to bash-maintainers@ai.MIT.Edu, while
  320.    suggestions and philosophical bug reports may be mailed to
  321.    bug-bash@ai.MIT.Edu or posted to the Usenet newsgroup gnu.bash.bug,
  322.    the source is widely available on many ftp sites, and is subject to
  323.    the GNU copyleft licence.
  324.    
  325.    Tcsh is available by ftp from ftp:tesla.ee.cornel.edu and several
  326.    other places.
  327.    
  328.    Rc is available by ftp from ftp:viz.tamu.edu/pub/rc and several other
  329.    places. An FAQ exists and is posted frequently to comp.unix.shell and
  330.    other places. The Rc mailing list may be subscribed to by sending mail
  331.    to rc-request@hawkwind.utcs.toronto.edu, this, the manual page and
  332.    the Rc FAQ are the main sources of information for this shell.
  333.    
  334.    Zsh is now maintained by the zsh mailing list, which can be subscribed
  335.    to by sending email to Majordomo@sterling.com containing subscribe
  336.    zsh-list, there is also an FAQ which is posted frequently to
  337.    comp.unix.shell. The manual page, the Z-shell FAQ and the zsh-list are
  338.    the main sources of information for this shell.
  339.    
  340.    Questions on any of the UNIX shells and on shell script programming,
  341.    may be posted to the Usenet newsgroup comp.unix.shell a quick response
  342.    can normally be expected, especially on subjects relating to the more
  343.    common shells.
  344.    
  345. Copyright and Disclaimer
  346.  
  347.     Copyright to this document is kept by the author, but freedom is
  348.    given to distribute it as long as no money is made from its
  349.    distribution, without the prior concent of the author. The author also
  350.    does not guarantee that the information it contains is correct,
  351.    although every effort is done to ensure that it is.
  352.    
  353.    Email relating to the content of this document should be sent to
  354.    shell-diff@gryphon.demon.co.uk.
  355.    
  356.     Brian Blackmore, bnb@gryphon.demon.co.uk
  357.  
  358.