home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15795 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  9.2 KB

  1. Xref: sparky comp.unix.questions:15795 comp.unix.shell:5448 news.answers:5366
  2. Path: sparky!uunet!spool.mu.edu!enterpoop.mit.edu!senator-bedfellow.mit.edu!senator-bedfellow.mit.edu!usenet
  3. From: tmatimar@empress.com (Ted M A Timar)
  4. Newsgroups: comp.unix.questions,comp.unix.shell,news.answers
  5. Subject: Unix - Frequently Asked Questions (5/7) [Frequent posting]
  6. Supersedes: <unix-faq/faq/part5_726386543@athena.mit.edu>
  7. Followup-To: comp.unix.questions
  8. Date: 21 Jan 1993 06:03:06 GMT
  9. Organization: Empress Software
  10. Lines: 230
  11. Approved: news-answers-request@MIT.Edu
  12. Distribution: world
  13. Expires: 18 Feb 1993 06:02:22 GMT
  14. Message-ID: <unix-faq/faq/part5_727596142@athena.mit.edu>
  15. References: <unix-faq/faq/contents_727596142@athena.mit.edu>
  16. NNTP-Posting-Host: pit-manager.mit.edu
  17. X-Last-Updated: 1992/12/09
  18.  
  19. Archive-name: unix-faq/faq/part5
  20. Version: $Id: part5,v 2.1 92/12/04 07:43:55 tmatimar Exp $
  21.  
  22. These seven articles contain the answers to some Frequently Asked
  23. Questions often seen in comp.unix.questions and comp.unix.shell.
  24. Please don't ask these questions again, they've been answered plenty
  25. of times already - and please don't flame someone just because they may
  26. not have read this particular posting.  Thank you.
  27.  
  28. These articles are divided approximately as follows:
  29.  
  30.       1.*) General questions.
  31.       2.*) Relatively basic questions, likely to be asked by beginners.
  32.       3.*) Intermediate questions.
  33.       4.*) Advanced questions, likely to be asked by people who thought
  34.        they already knew all of the answers.
  35.       5.*) Questions pertaining to the various shells, and the differences.
  36.       6.*) An overview of Unix variants.
  37.       7.*) An comparison of configuration management systems (RCS, SCCS).
  38.  
  39. This article includes answers to:
  40.  
  41.       5.1)  Can shells be classified into categories?
  42.       5.2)  How do I "include" one shell script from within another
  43.             shell script?
  44.       5.3)  Do all shells have aliases?  Is there something else that
  45.             can be used?
  46.       5.4)  How are shell variables assigned?
  47.       5.5)  How can I tell if I am running an interactive shell?
  48.       5.6)  What "dot" files do the various shells use?
  49.       5.7)  I would like to know more about the differences between the
  50.             various shells.  Is this information available some place?
  51.  
  52. If you're looking for the answer to, say, question 5.5, and want to skip
  53. everything else, you can search ahead for the regular expression "^5.5)".
  54.  
  55. While these are all legitimate questions, they seem to crop up in
  56. comp.unix.questions or comp.unix.shell on an annual basis, usually
  57. followed by plenty of replies (only some of which are correct) and then
  58. a period of griping about how the same questions keep coming up.  You
  59. may also like to read the monthly article "Answers to Frequently Asked
  60. Questions" in the newsgroup "news.announce.newusers", which will tell
  61. you what "UNIX" stands for.
  62.  
  63. With the variety of Unix systems in the world, it's hard to guarantee
  64. that these answers will work everywhere.  Read your local manual pages
  65. before trying anything suggested here.  If you have suggestions or
  66. corrections for any of these answers, please send them to to
  67. tmatimar@empress.com.
  68.  
  69. 5.1)  Can shells be classified into categories?
  70.  
  71.       From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  72.       Date: Wed, 7 Oct 92 14:28:18 -0500
  73.  
  74.       In general there are two main class of shells.  The first class
  75.       are those shells derived from the Bourne shell which includes sh,
  76.       ksh, bash, and zsh.  The second class are those shells derived
  77.       from C shell and include csh and tcsh.  In addition there is rc
  78.       which most people consider to be in a "class by itself" although
  79.       some people might argue that rc belongs in the Bourne shell class.
  80.  
  81.       With the classification above, using care, it is possible to
  82.       write scripts that will work for all the shells from the Bourne
  83.       shell category, and write other scripts that will work for all of
  84.       the shells from the C shell category.
  85.  
  86. 5.2)  How do I "include" one shell script from within another shell script?
  87.  
  88.       From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  89.       Date: Wed, 7 Oct 92 14:28:18 -0500
  90.  
  91.       All of the shells from the Bourne shell category (including rc)
  92.       use the "." command.  All of the shells from the C shell category
  93.       use "source".
  94.  
  95. 5.3)  Do all shells have aliases?  Is there something else that can be used?
  96.  
  97.       From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  98.       Date: Wed, 7 Oct 92 14:28:18 -0500
  99.  
  100.       All of the major shells other than sh have aliases, but they
  101.       don't all work the same way.  For example, some don't accept
  102.       arguments.
  103.       
  104.       Although not strictly equivalent, shell functions (which exist in
  105.       all shells from the Bourne shell category) have almost the same
  106.       functionality of aliases.  Shell functions can do things that
  107.       aliases can't do.
  108.       
  109.       Use unalias to remove aliases and unset to remove functions.
  110.  
  111. 5.4)  How are shell variables assigned?
  112.  
  113.       From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  114.       Date: Wed, 7 Oct 92 14:28:18 -0500
  115.  
  116.       The shells from the C shell category use "set variable=value" for
  117.       variables local to the shell and "setenv variable value" for
  118.       environment variables.  To get rid of variables in these shells
  119.       use unset and unsetenv.  The shells from the Bourne shell
  120.       category use "variable=value" and may require an "export
  121.       VARIABLE_NAME" to place the variable into the environment.  To
  122.       get rid of the variables use unset.
  123.  
  124. 5.5)  How can I tell if I am running an interactive shell?
  125.  
  126.       From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  127.       From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  128.       Date: Fri, 23 Oct 92 11:59:19 -0600
  129.  
  130.       In the C shell category, look for the variable $prompt.
  131.  
  132.       In the Bourne shell category, you can look for the variable $PS1,
  133.       however, it is better to check the variable $-.  If $- contains
  134.       an 'i', the shell is interactive.  Test like so:
  135.  
  136.       case $- in
  137.       *i*)    # do things for interactive shell
  138.               ;;
  139.       *)      # do things for non-interactive shell
  140.               ;;
  141.       esac
  142.  
  143. 5.6)  What "dot" files do the various shells use?
  144.  
  145.       From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  146.       From: tmb@idiap.ch (Thomas M. Breuel)
  147.       Date: Wed, 28 Oct 92 03:30:36 +0100
  148.  
  149.       Although this may not be a complete listing, this provides the
  150.       majority of information.
  151.  
  152.       csh
  153.       Some versions have system-wide .cshrc and .login files.  Every
  154.       version puts them in different places.
  155.  
  156.       Start-up (in this order):
  157.           .cshrc   - always.
  158.           .login   - login shells.
  159.  
  160.       Upon termination:
  161.               .logout  - login shells.
  162.  
  163.       Others:
  164.           .history - saves the history (based on $savehist).
  165.  
  166.       tcsh
  167.       Start-up (in this order):
  168.           /etc/csh.cshrc - always.
  169.           /etc/csh.login - login shells.
  170.           .tcshrc        - always.
  171.           .cshrc         - if no .tcshrc was present.
  172.           .login         - login shells
  173.  
  174.       Upon termination:
  175.               .logout        - login shells.
  176.  
  177.       Others:
  178.           .history       - saves the history (based on $savehist).
  179.           .cshdirs       - saves the directory stack.
  180.  
  181.       sh
  182.       Start-up (in this order):
  183.           /etc/profile - login shells.
  184.           .profile     - login shells.
  185.  
  186.       Upon termination:
  187.           any command (or script) specified using the command:
  188.          trap "command" 0
  189.  
  190.       ksh
  191.       Start-up (in this order):
  192.           /etc/profile - login shells.
  193.           .profile     - login shells.
  194.           $ENV         - always, if it is set.
  195.  
  196.       Upon termination:
  197.           any command (or script) specified using the command:
  198.          trap "command" 0
  199.  
  200.       bash
  201.       Start-up (in this order):
  202.               /etc/profile  - login shells.
  203.               .bash_profile - login shells.
  204.               .profile      - login if no .bash_profile is present.
  205.               .bashrc       - interactive non-login shells.
  206.               $ENV          - always, if it is set.
  207.  
  208.       Upon termination:
  209.               .bash_logout  - login shells.
  210.  
  211.       Others:
  212.               .inputrc      - Readline initialization.
  213.  
  214.       zsh
  215.       Start-up (in this order):
  216.               .zshenv   - always, unless -f is specified.
  217.               .zprofile - login shells.
  218.               .zshrc    - interactive shells, unless -f is specified.
  219.               .zlogin   - login shells.
  220.  
  221.       Upon termination:
  222.               .zlogout  - login shells.
  223.  
  224.       rc
  225.       Start-up:
  226.               .rcrc - login shells
  227.  
  228. 5.7)  I would like to know more about the differences between the
  229.       various shells.  Is this information available some place?
  230.  
  231.       From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  232.       Date: Wed, 7 Oct 92 14:28:18 -0500
  233.  
  234.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  235.       rc is available via anon.  ftp in several places:
  236.  
  237.       cs.uwp.edu (131.210.1.4):pub/vi/shell-100.BetaA.Z
  238.       alf.uib.no (129.177.30.3):pub/lpf/misc/shell-100.BetaA.Z
  239.       utsun.s.u-tokyo.ac.jp (133.11.11.11):misc/vi/shell-100.BetaA.Z
  240.  
  241.       This file compares the flags, the programming syntax,
  242.       input/output redirection, and parameters/shell environment
  243.       variables.  It doesn't discuss what dot files are used and the
  244.       inheritance for environment variables and functions.
  245.  
  246. -- 
  247. Ted Timar - tmatimar@empress.com
  248. Empress Software, 3100 Steeles Ave E, Markham, Ont., Canada L3R 8T3
  249.