home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / internet / faq / englisch / unix-shell-differences < prev    next >
Encoding:
Text File  |  1995-04-11  |  17.7 KB  |  344 lines

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