home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / infoguide / advanced / unix / unix-faq-part5 < prev    next >
Text File  |  1997-12-01  |  10KB  |  278 lines

  1. Archive-name: unix-faq/faq/part5
  2. Version: $Id: part5,v 2.4 1994/01/14 14:58:06 tmatimar Exp $
  3.  
  4. These seven articles contain the answers to some Frequently Asked
  5. Questions often seen in comp.unix.questions and comp.unix.shell.
  6. Please don't ask these questions again, they've been answered plenty
  7. of times already - and please don't flame someone just because they may
  8. not have read this particular posting.  Thank you.
  9.  
  10. This collection of documents is Copyright (c) 1994, Ted Timar.
  11. All rights reserved.  Permission to distribute the collection is
  12. hereby granted providing that distribution is electronic, no money
  13. is involved, reasonable attempts are made to use the latest version
  14. and all credits and this copyright notice are maintained.
  15. Other requests for distribution will be considered.
  16.  
  17. All information here has been contributed with good intentions, but
  18. none of it is guaranteed either by the contributors or myself to be
  19. accurate.  The users of this information take all responsibility for
  20. any damage that may occur.
  21.  
  22. Many FAQs, including this one, are available on the archive site
  23. rtfm.mit.edu in the directory pub/usenet/news.answers.
  24. The name under which a FAQ is archived appears in the "Archive-Name:"
  25. line at the top of the article.  This FAQ is archived as
  26. "unix-faq/faq/part[1-7]".
  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. ----------------------------------------------------------------------
  70.  
  71. Subject: Can shells be classified into categories?
  72. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  73. Date: Wed, 7 Oct 92 14:28:18 -0500
  74.  
  75.  
  76. 5.1)  Can shells be classified into categories?
  77.  
  78.       In general there are two main class of shells.  The first class
  79.       are those shells derived from the Bourne shell which includes sh,
  80.       ksh, bash, and zsh.  The second class are those shells derived
  81.       from C shell and include csh and tcsh.  In addition there is rc
  82.       which most people consider to be in a "class by itself" although
  83.       some people might argue that rc belongs in the Bourne shell class.
  84.  
  85.       With the classification above, using care, it is possible to
  86.       write scripts that will work for all the shells from the Bourne
  87.       shell category, and write other scripts that will work for all of
  88.       the shells from the C shell category.
  89.  
  90. ------------------------------
  91.  
  92. Subject: How do I "include" one shell script from within another shell script?
  93. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  94. Date: Wed, 7 Oct 92 14:28:18 -0500
  95.  
  96. 5.2)  How do I "include" one shell script from within another shell script?
  97.  
  98.       All of the shells from the Bourne shell category (including rc)
  99.       use the "." command.  All of the shells from the C shell category
  100.       use "source".
  101.  
  102. ------------------------------
  103.  
  104. Subject: Do all shells have aliases?  Is there something else that can be used?
  105. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  106. Date: Wed, 7 Oct 92 14:28:18 -0500
  107.  
  108. 5.3)  Do all shells have aliases?  Is there something else that can be used?
  109.  
  110.       All of the major shells other than sh have aliases, but they
  111.       don't all work the same way.  For example, some don't accept
  112.       arguments.
  113.       
  114.       Although not strictly equivalent, shell functions (which exist in
  115.       most shells from the Bourne shell category) have almost the same
  116.       functionality of aliases.  Shell functions can do things that
  117.       aliases can't do.  Shell functions did not exist in bourne shells
  118.       derived from Version 7 Unix, which includes System III and BSD 4.2.
  119.       BSD 4.3 and System V shells do support shell functions.
  120.       
  121.       Use unalias to remove aliases and unset to remove functions.
  122.  
  123. ------------------------------
  124.  
  125. Subject: How are shell variables assigned?
  126. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  127. Date: Wed, 7 Oct 92 14:28:18 -0500
  128.  
  129. 5.4)  How are shell variables assigned?
  130.  
  131.       The shells from the C shell category use "set variable=value" for
  132.       variables local to the shell and "setenv variable value" for
  133.       environment variables.  To get rid of variables in these shells
  134.       use unset and unsetenv.  The shells from the Bourne shell
  135.       category use "variable=value" and may require an "export
  136.       VARIABLE_NAME" to place the variable into the environment.  To
  137.       get rid of the variables use unset.
  138.  
  139. ------------------------------
  140.  
  141. Subject: How can I tell if I am running an interactive shell?
  142. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  143. >From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  144. Date: Fri, 23 Oct 92 11:59:19 -0600
  145.  
  146. 5.5)  How can I tell if I am running an interactive shell?
  147.  
  148.       In the C shell category, look for the variable $prompt.
  149.  
  150.       In the Bourne shell category, you can look for the variable $PS1,
  151.       however, it is better to check the variable $-.  If $- contains
  152.       an 'i', the shell is interactive.  Test like so:
  153.  
  154.       case $- in
  155.       *i*)    # do things for interactive shell
  156.               ;;
  157.       *)      # do things for non-interactive shell
  158.               ;;
  159.       esac
  160.  
  161. ------------------------------
  162.  
  163. Subject: What "dot" files do the various shells use?
  164. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  165. >From: tmb@idiap.ch (Thomas M. Breuel)
  166. Date: Wed, 28 Oct 92 03:30:36 +0100
  167.  
  168. 5.6)  What "dot" files do the various shells use?
  169.  
  170.       Although this may not be a complete listing, this provides the
  171.       majority of information.
  172.  
  173.       csh
  174.       Some versions have system-wide .cshrc and .login files.  Every
  175.       version puts them in different places.
  176.  
  177.       Start-up (in this order):
  178.           .cshrc   - always.
  179.           .login   - login shells.
  180.  
  181.       Upon termination:
  182.               .logout  - login shells.
  183.  
  184.       Others:
  185.           .history - saves the history (based on $savehist).
  186.  
  187.       tcsh
  188.       Start-up (in this order):
  189.           /etc/csh.cshrc - always.
  190.           /etc/csh.login - login shells.
  191.           .tcshrc        - always.
  192.           .cshrc         - if no .tcshrc was present.
  193.           .login         - login shells
  194.  
  195.       Upon termination:
  196.               .logout        - login shells.
  197.  
  198.       Others:
  199.           .history       - saves the history (based on $savehist).
  200.           .cshdirs       - saves the directory stack.
  201.  
  202.       sh
  203.       Start-up (in this order):
  204.           /etc/profile - login shells.
  205.           .profile     - login shells.
  206.  
  207.       Upon termination:
  208.           any command (or script) specified using the command:
  209.          trap "command" 0
  210.  
  211.       ksh
  212.       Start-up (in this order):
  213.           /etc/profile - login shells.
  214.           .profile     - login shells.
  215.           $ENV         - always, if it is set.
  216.  
  217.       Upon termination:
  218.           any command (or script) specified using the command:
  219.          trap "command" 0
  220.  
  221.       bash
  222.       Start-up (in this order):
  223.               /etc/profile  - login shells.
  224.               .bash_profile - login shells.
  225.               .profile      - login if no .bash_profile is present.
  226.               .bashrc       - interactive non-login shells.
  227.               $ENV          - always, if it is set.
  228.  
  229.       Upon termination:
  230.               .bash_logout  - login shells.
  231.  
  232.       Others:
  233.               .inputrc      - Readline initialization.
  234.  
  235.       zsh
  236.       Start-up (in this order):
  237.               .zshenv   - always, unless -f is specified.
  238.               .zprofile - login shells.
  239.               .zshrc    - interactive shells, unless -f is specified.
  240.               .zlogin   - login shells.
  241.  
  242.       Upon termination:
  243.               .zlogout  - login shells.
  244.  
  245.       rc
  246.       Start-up:
  247.               .rcrc - login shells
  248.  
  249. ------------------------------
  250.  
  251. Subject: I would like to know more about the differences ... ?
  252. >From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  253. Date: Wed, 7 Oct 92 14:28:18 -0500
  254.  
  255. 5.7)  I would like to know more about the differences between the
  256.       various shells.  Is this information available some place?
  257.  
  258.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  259.       rc is available via anon.  ftp in several places:
  260.  
  261.       cs.uwp.edu (131.210.1.4):pub/vi/docs/shell-100.BetaA.Z
  262.       alf.uib.no (129.177.30.3):pub/lpf/misc/shell-100.BetaA.Z
  263.       utsun.s.u-tokyo.ac.jp (133.11.11.11):misc/vi/shell-100.BetaA.Z
  264.  
  265.       This file compares the flags, the programming syntax,
  266.       input/output redirection, and parameters/shell environment
  267.       variables.  It doesn't discuss what dot files are used and the
  268.       inheritance for environment variables and functions.
  269.  
  270. ------------------------------
  271.  
  272. End of unix/faq Digest part 5 of 7
  273. **********************************
  274.  
  275. -- 
  276. Ted Timar - tmatimar@empress.com
  277. Empress Software, 3100 Steeles Ave E, Markham, Ont., Canada L3R 8T3
  278.