home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / unix-faq / faq / part5 < prev    next >
Encoding:
Internet Message Format  |  2004-05-12  |  11.5 KB

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <unix-faq/faq/part5_1084272547@rtfm.mit.edu>
  3. Supersedes: <unix-faq/faq/part5_1083581613@rtfm.mit.edu>
  4. Expires: 8 Jun 2004 10:49:07 GMT
  5. References: <unix-faq/faq/contents_1084272547@rtfm.mit.edu>
  6. X-Last-Updated: 1996/06/11
  7. From: tmatimar@isgtec.com (Ted Timar)
  8. Distribution: world
  9. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  10. Followup-To: comp.unix.questions
  11. Organization: ISG Technologies, Inc
  12. Subject: Unix - Frequently Asked Questions (5/7) [Frequent posting]
  13. Approved: news-answers-request@MIT.Edu
  14. Originator: faqserv@penguin-lust.MIT.EDU
  15. Date: 11 May 2004 10:50:00 GMT
  16. Lines: 279
  17. NNTP-Posting-Host: penguin-lust.mit.edu
  18. X-Trace: 1084272600 senator-bedfellow.mit.edu 574 18.181.0.29
  19. Xref: senator-bedfellow.mit.edu comp.unix.questions:195438 comp.unix.shell:165515 comp.answers:57118 news.answers:271074
  20.  
  21. Archive-name: unix-faq/faq/part5
  22. Version: $Id: part5,v 2.9 1996/06/11 13:07:56 tmatimar Exp $
  23.  
  24. These seven articles contain the answers to some Frequently Asked
  25. Questions often seen in comp.unix.questions and comp.unix.shell.
  26. Please don't ask these questions again, they've been answered plenty
  27. of times already - and please don't flame someone just because they may
  28. not have read this particular posting.  Thank you.
  29.  
  30. This collection of documents is Copyright (c) 1994, Ted Timar, except
  31. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  32. All rights reserved.  Permission to distribute the collection is
  33. hereby granted providing that distribution is electronic, no money
  34. is involved, reasonable attempts are made to use the latest version
  35. and all credits and this copyright notice are maintained.
  36. Other requests for distribution will be considered.  All reasonable
  37. requests will be granted.
  38.  
  39. All information here has been contributed with good intentions, but
  40. none of it is guaranteed either by the contributors or myself to be
  41. accurate.  The users of this information take all responsibility for
  42. any damage that may occur.
  43.  
  44. Many FAQs, including this one, are available on the archive site
  45. rtfm.mit.edu in the directory pub/usenet/news.answers.
  46. The name under which a FAQ is archived appears in the "Archive-Name:"
  47. line at the top of the article.  This FAQ is archived as
  48. "unix-faq/faq/part[1-7]".
  49.  
  50. These articles are divided approximately as follows:
  51.  
  52.       1.*) General questions.
  53.       2.*) Relatively basic questions, likely to be asked by beginners.
  54.       3.*) Intermediate questions.
  55.       4.*) Advanced questions, likely to be asked by people who thought
  56.            they already knew all of the answers.
  57.       5.*) Questions pertaining to the various shells, and the differences.
  58.       6.*) An overview of Unix variants.
  59.       7.*) An comparison of configuration management systems (RCS, SCCS).
  60.  
  61. This article includes answers to:
  62.  
  63.       5.1)  Can shells be classified into categories?
  64.       5.2)  How do I "include" one shell script from within another
  65.             shell script?
  66.       5.3)  Do all shells have aliases?  Is there something else that
  67.             can be used?
  68.       5.4)  How are shell variables assigned?
  69.       5.5)  How can I tell if I am running an interactive shell?
  70.       5.6)  What "dot" files do the various shells use?
  71.       5.7)  I would like to know more about the differences between the
  72.             various shells.  Is this information available some place?
  73.  
  74. If you're looking for the answer to, say, question 5.5, and want to skip
  75. everything else, you can search ahead for the regular expression "^5.5)".
  76.  
  77. While these are all legitimate questions, they seem to crop up in
  78. comp.unix.questions or comp.unix.shell on an annual basis, usually
  79. followed by plenty of replies (only some of which are correct) and then
  80. a period of griping about how the same questions keep coming up.  You
  81. may also like to read the monthly article "Answers to Frequently Asked
  82. Questions" in the newsgroup "news.announce.newusers", which will tell
  83. you what "UNIX" stands for.
  84.  
  85. With the variety of Unix systems in the world, it's hard to guarantee
  86. that these answers will work everywhere.  Read your local manual pages
  87. before trying anything suggested here.  If you have suggestions or
  88. corrections for any of these answers, please send them to to
  89. tmatimar@isgtec.com.
  90.  
  91. ----------------------------------------------------------------------
  92.  
  93. Subject: Can shells be classified into categories?
  94. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  95. Date: Wed, 7 Oct 92 14:28:18 -0500
  96.  
  97.  
  98. 5.1)  Can shells be classified into categories?
  99.  
  100.       In general there are two main class of shells.  The first class
  101.       are those shells derived from the Bourne shell which includes sh,
  102.       ksh, bash, and zsh.  The second class are those shells derived
  103.       from C shell and include csh and tcsh.  In addition there is rc
  104.       which most people consider to be in a "class by itself" although
  105.       some people might argue that rc belongs in the Bourne shell class.
  106.  
  107.       With the classification above, using care, it is possible to
  108.       write scripts that will work for all the shells from the Bourne
  109.       shell category, and write other scripts that will work for all of
  110.       the shells from the C shell category.
  111.  
  112. ------------------------------
  113.  
  114. Subject: How do I "include" one shell script from within another shell script?
  115. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  116. Date: Wed, 7 Oct 92 14:28:18 -0500
  117.  
  118. 5.2)  How do I "include" one shell script from within another shell script?
  119.  
  120.       All of the shells from the Bourne shell category (including rc)
  121.       use the "." command.  All of the shells from the C shell category
  122.       use "source".
  123.  
  124. ------------------------------
  125.  
  126. Subject: Do all shells have aliases?  Is there something else that can be used?
  127. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  128. Date: Wed, 7 Oct 92 14:28:18 -0500
  129.  
  130. 5.3)  Do all shells have aliases?  Is there something else that can be used?
  131.  
  132.       All of the major shells other than sh have aliases, but they
  133.       don't all work the same way.  For example, some don't accept
  134.       arguments.
  135.       
  136.       Although not strictly equivalent, shell functions (which exist in
  137.       most shells from the Bourne shell category) have almost the same
  138.       functionality of aliases.  Shell functions can do things that
  139.       aliases can't do.  Shell functions did not exist in bourne shells
  140.       derived from Version 7 Unix, which includes System III and BSD 4.2.
  141.       BSD 4.3 and System V shells do support shell functions.
  142.       
  143.       Use unalias to remove aliases and unset to remove functions.
  144.  
  145. ------------------------------
  146.  
  147. Subject: How are shell variables assigned?
  148. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  149. Date: Wed, 7 Oct 92 14:28:18 -0500
  150.  
  151. 5.4)  How are shell variables assigned?
  152.  
  153.       The shells from the C shell category use "set variable=value" for
  154.       variables local to the shell and "setenv variable value" for
  155.       environment variables.  To get rid of variables in these shells
  156.       use unset and unsetenv.  The shells from the Bourne shell
  157.       category use "variable=value" and may require an "export
  158.       VARIABLE_NAME" to place the variable into the environment.  To
  159.       get rid of the variables use unset.
  160.  
  161. ------------------------------
  162.  
  163. Subject: How can I tell if I am running an interactive shell?
  164. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  165. >From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  166. Date: Fri, 23 Oct 92 11:59:19 -0600
  167.  
  168. 5.5)  How can I tell if I am running an interactive shell?
  169.  
  170.       In the C shell category, look for the variable $prompt.
  171.  
  172.       In the Bourne shell category, you can look for the variable $PS1,
  173.       however, it is better to check the variable $-.  If $- contains
  174.       an 'i', the shell is interactive.  Test like so:
  175.  
  176.           case $- in
  177.           *i*)    # do things for interactive shell
  178.                   ;;
  179.           *)      # do things for non-interactive shell
  180.                   ;;
  181.           esac
  182.  
  183. ------------------------------
  184.  
  185. Subject: What "dot" files do the various shells use?
  186. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  187. >From: tmb@idiap.ch (Thomas M. Breuel)
  188. Date: Wed, 28 Oct 92 03:30:36 +0100
  189.  
  190. 5.6)  What "dot" files do the various shells use?
  191.  
  192.       Although this may not be a complete listing, this provides the
  193.       majority of information.
  194.  
  195.       csh
  196.           Some versions have system-wide .cshrc and .login files.  Every
  197.           version puts them in different places.
  198.  
  199.           Start-up (in this order):
  200.               .cshrc   - always; unless the -f option is used.
  201.               .login   - login shells.
  202.  
  203.           Upon termination:
  204.               .logout  - login shells.
  205.  
  206.           Others:
  207.               .history - saves the history (based on $savehist).
  208.  
  209.       tcsh
  210.           Start-up (in this order):
  211.               /etc/csh.cshrc - always.
  212.               /etc/csh.login - login shells.
  213.               .tcshrc        - always.
  214.               .cshrc         - if no .tcshrc was present.
  215.               .login         - login shells
  216.  
  217.           Upon termination:
  218.               .logout        - login shells.
  219.  
  220.           Others:
  221.               .history       - saves the history (based on $savehist).
  222.               .cshdirs       - saves the directory stack.
  223.  
  224.       sh
  225.           Start-up (in this order):
  226.               /etc/profile - login shells.
  227.               .profile     - login shells.
  228.  
  229.           Upon termination:
  230.               any command (or script) specified using the command:
  231.                  trap "command" 0
  232.  
  233.       ksh
  234.           Start-up (in this order):
  235.               /etc/profile - login shells.
  236.               .profile     - login shells; unless the -p option is used.
  237.               $ENV         - always, if it is set; unless the -p option is used.
  238.               /etc/suid_profile - when the -p option is used.
  239.  
  240.           Upon termination:
  241.               any command (or script) specified using the command:
  242.                  trap "command" 0
  243.  
  244.       bash
  245.           Start-up (in this order):
  246.               /etc/profile  - login shells.
  247.               .bash_profile - login shells.
  248.               .profile      - login if no .bash_profile is present.
  249.               .bashrc       - interactive non-login shells.
  250.               $ENV          - always, if it is set.
  251.  
  252.           Upon termination:
  253.               .bash_logout  - login shells.
  254.  
  255.           Others:
  256.               .inputrc      - Readline initialization.
  257.  
  258.       zsh
  259.           Start-up (in this order):
  260.               .zshenv   - always, unless -f is specified.
  261.               .zprofile - login shells.
  262.               .zshrc    - interactive shells, unless -f is specified.
  263.               .zlogin   - login shells.
  264.  
  265.           Upon termination:
  266.               .zlogout  - login shells.
  267.  
  268.       rc
  269.           Start-up:
  270.               .rcrc - login shells
  271.  
  272. ------------------------------
  273.  
  274. Subject: I would like to know more about the differences ... ?
  275. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  276. Date: Wed, 7 Oct 92 14:28:18 -0500
  277.  
  278. 5.7)  I would like to know more about the differences between the
  279.       various shells.  Is this information available some place?
  280.  
  281.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  282.       rc is available via anon.  ftp in several places:
  283.  
  284.       ftp.uwp.edu (204.95.162.190):pub/vi/docs/shell-100.BetaA.Z
  285.       utsun.s.u-tokyo.ac.jp:misc/vi-archive/docs/shell-100.BetaA.Z
  286.  
  287.       This file compares the flags, the programming syntax,
  288.       input/output redirection, and parameters/shell environment
  289.       variables.  It doesn't discuss what dot files are used and the
  290.       inheritance for environment variables and functions.
  291.  
  292. ------------------------------
  293.  
  294. End of unix/faq Digest part 5 of 7
  295. **********************************
  296.  
  297. -- 
  298. Ted Timar - tmatimar@isgtec.com
  299. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  300.