home *** CD-ROM | disk | FTP | other *** search
/ Danny Amor's Online Library / Danny Amor's Online Library - Volume 1.iso / html / faqs / faq / unix-faq / faq.part5 < prev    next >
Encoding:
Text File  |  1995-07-25  |  10.7 KB  |  285 lines

  1. Subject: Unix - Frequently Asked Questions (5/7) [Frequent posting]
  2. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  3. From: tmatimar@isgtec.com (Ted Timar)
  4. Date: 18 Nov 1994 07:49:29 GMT
  5.  
  6. Archive-name: unix-faq/faq/part5
  7. Version: $Id: part5,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  8.  
  9. These seven articles contain the answers to some Frequently Asked
  10. Questions often seen in comp.unix.questions and comp.unix.shell.
  11. Please don't ask these questions again, they've been answered plenty
  12. of times already - and please don't flame someone just because they may
  13. not have read this particular posting.  Thank you.
  14.  
  15. This collection of documents is Copyright (c) 1994, Ted Timar, except
  16. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  17. All rights reserved.  Permission to distribute the collection is
  18. hereby granted providing that distribution is electronic, no money
  19. is involved, reasonable attempts are made to use the latest version
  20. and all credits and this copyright notice are maintained.
  21. Other requests for distribution will be considered.  All reasonable
  22. requests will be granted.
  23.  
  24. All information here has been contributed with good intentions, but
  25. none of it is guaranteed either by the contributors or myself to be
  26. accurate.  The users of this information take all responsibility for
  27. any damage that may occur.
  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@isgtec.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.       most 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.  Shell functions did not exist in bourne shells
  125.       derived from Version 7 Unix, which includes System III and BSD 4.2.
  126.       BSD 4.3 and System V shells do support shell functions.
  127.       
  128.       Use unalias to remove aliases and unset to remove functions.
  129.  
  130. ------------------------------
  131.  
  132. Subject: How are shell variables assigned?
  133. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  134. Date: Wed, 7 Oct 92 14:28:18 -0500
  135.  
  136. 5.4)  How are shell variables assigned?
  137.  
  138.       The shells from the C shell category use "set variable=value" for
  139.       variables local to the shell and "setenv variable value" for
  140.       environment variables.  To get rid of variables in these shells
  141.       use unset and unsetenv.  The shells from the Bourne shell
  142.       category use "variable=value" and may require an "export
  143.       VARIABLE_NAME" to place the variable into the environment.  To
  144.       get rid of the variables use unset.
  145.  
  146. ------------------------------
  147.  
  148. Subject: How can I tell if I am running an interactive shell?
  149. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  150. From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  151. Date: Fri, 23 Oct 92 11:59:19 -0600
  152.  
  153. 5.5)  How can I tell if I am running an interactive shell?
  154.  
  155.       In the C shell category, look for the variable $prompt.
  156.  
  157.       In the Bourne shell category, you can look for the variable $PS1,
  158.       however, it is better to check the variable $-.  If $- contains
  159.       an 'i', the shell is interactive.  Test like so:
  160.  
  161.           case $- in
  162.           *i*)    # do things for interactive shell
  163.                   ;;
  164.           *)      # do things for non-interactive shell
  165.                   ;;
  166.           esac
  167.  
  168. ------------------------------
  169.  
  170. Subject: What "dot" files do the various shells use?
  171. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  172. From: tmb@idiap.ch (Thomas M. Breuel)
  173. Date: Wed, 28 Oct 92 03:30:36 +0100
  174.  
  175. 5.6)  What "dot" files do the various shells use?
  176.  
  177.       Although this may not be a complete listing, this provides the
  178.       majority of information.
  179.  
  180.       csh
  181.           Some versions have system-wide .cshrc and .login files.  Every
  182.           version puts them in different places.
  183.  
  184.           Start-up (in this order):
  185.               .cshrc   - always.
  186.               .login   - login shells.
  187.  
  188.           Upon termination:
  189.               .logout  - login shells.
  190.  
  191.           Others:
  192.               .history - saves the history (based on $savehist).
  193.  
  194.       tcsh
  195.           Start-up (in this order):
  196.               /etc/csh.cshrc - always.
  197.               /etc/csh.login - login shells.
  198.               .tcshrc        - always.
  199.               .cshrc         - if no .tcshrc was present.
  200.               .login         - login shells
  201.  
  202.           Upon termination:
  203.               .logout        - login shells.
  204.  
  205.           Others:
  206.               .history       - saves the history (based on $savehist).
  207.               .cshdirs       - saves the directory stack.
  208.  
  209.       sh
  210.           Start-up (in this order):
  211.               /etc/profile - login shells.
  212.               .profile     - login shells.
  213.  
  214.           Upon termination:
  215.               any command (or script) specified using the command:
  216.                  trap "command" 0
  217.  
  218.       ksh
  219.           Start-up (in this order):
  220.               /etc/profile - login shells.
  221.               .profile     - login shells.
  222.               $ENV         - always, if it is set.
  223.  
  224.           Upon termination:
  225.               any command (or script) specified using the command:
  226.                  trap "command" 0
  227.  
  228.       bash
  229.           Start-up (in this order):
  230.               /etc/profile  - login shells.
  231.               .bash_profile - login shells.
  232.               .profile      - login if no .bash_profile is present.
  233.               .bashrc       - interactive non-login shells.
  234.               $ENV          - always, if it is set.
  235.  
  236.           Upon termination:
  237.               .bash_logout  - login shells.
  238.  
  239.           Others:
  240.               .inputrc      - Readline initialization.
  241.  
  242.       zsh
  243.           Start-up (in this order):
  244.               .zshenv   - always, unless -f is specified.
  245.               .zprofile - login shells.
  246.               .zshrc    - interactive shells, unless -f is specified.
  247.               .zlogin   - login shells.
  248.  
  249.           Upon termination:
  250.               .zlogout  - login shells.
  251.  
  252.       rc
  253.           Start-up:
  254.               .rcrc - login shells
  255.  
  256. ------------------------------
  257.  
  258. Subject: I would like to know more about the differences ... ?
  259. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  260. Date: Wed, 7 Oct 92 14:28:18 -0500
  261.  
  262. 5.7)  I would like to know more about the differences between the
  263.       various shells.  Is this information available some place?
  264.  
  265.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  266.       rc is available via anon.  ftp in several places:
  267.  
  268.       cs.uwp.edu (131.210.1.4):pub/vi/docs/shell-100.BetaA.Z
  269.       utsun.s.u-tokyo.ac.jp:misc/vi-archive/docs/shell-100.BetaA.Z
  270.  
  271.       This file compares the flags, the programming syntax,
  272.       input/output redirection, and parameters/shell environment
  273.       variables.  It doesn't discuss what dot files are used and the
  274.       inheritance for environment variables and functions.
  275.  
  276. ------------------------------
  277.  
  278. End of unix/faq Digest part 5 of 7
  279. **********************************
  280.  
  281. -- 
  282. Ted Timar - tmatimar@isgtec.com
  283. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  284.  
  285.