home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / answers / unix-faq / faq / part5 < prev    next >
Internet Message Format  |  1993-12-26  |  10KB

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