home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
answers
/
unix-faq
/
faq
/
part5
< prev
next >
Wrap
Internet Message Format
|
1993-12-26
|
10KB
Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!pad-thai.aktis.com!pad-thai.aktis.com!not-for-mail
From: tmatimar@empress.com (Ted M A Timar)
Newsgroups: comp.unix.questions,comp.unix.shell,news.answers,comp.answers
Subject: Unix - Frequently Asked Questions (5/7) Digest [Frequent posting]
Supersedes: <unix-faq/faq/part5_755758811@GZA.COM>
Followup-To: comp.unix.questions
Date: 27 Dec 1993 00:00:23 -0500
Organization: Empress Software
Lines: 263
Sender: faqserv@security.ov.com
Approved: news-answers-request@MIT.Edu
Distribution: world
Expires: 24 Jan 1994 05:00:09 GMT
Message-ID: <unix-faq/faq/part5_756968409@GZA.COM>
References: <unix-faq/faq/contents_756968409@GZA.COM>
NNTP-Posting-Host: pad-thai.aktis.com
X-Last-Updated: 1993/09/02
Xref: senator-bedfellow.mit.edu comp.unix.questions:66492 comp.unix.shell:14265 news.answers:16181 comp.answers:3153
Archive-name: unix-faq/faq/part5
Version: $Id: part5,v 2.3 1993/09/01 23:28:52 tmatimar Exp $
These seven articles contain the answers to some Frequently Asked
Questions often seen in comp.unix.questions and comp.unix.shell.
Please don't ask these questions again, they've been answered plenty
of times already - and please don't flame someone just because they may
not have read this particular posting. Thank you.
Many FAQs, including this one, are available on the archive site
rtfm.mit.edu in the directory pub/usenet/news.answers.
The name under which a FAQ is archived appears in the "Archive-Name:"
line at the top of the article. This FAQ is archived as
"unix-faq/faq/part[1-7]".
These articles are divided approximately as follows:
1.*) General questions.
2.*) Relatively basic questions, likely to be asked by beginners.
3.*) Intermediate questions.
4.*) Advanced questions, likely to be asked by people who thought
they already knew all of the answers.
5.*) Questions pertaining to the various shells, and the differences.
6.*) An overview of Unix variants.
7.*) An comparison of configuration management systems (RCS, SCCS).
This article includes answers to:
5.1) Can shells be classified into categories?
5.2) How do I "include" one shell script from within another
shell script?
5.3) Do all shells have aliases? Is there something else that
can be used?
5.4) How are shell variables assigned?
5.5) How can I tell if I am running an interactive shell?
5.6) What "dot" files do the various shells use?
5.7) I would like to know more about the differences between the
various shells. Is this information available some place?
If you're looking for the answer to, say, question 5.5, and want to skip
everything else, you can search ahead for the regular expression "^5.5)".
While these are all legitimate questions, they seem to crop up in
comp.unix.questions or comp.unix.shell on an annual basis, usually
followed by plenty of replies (only some of which are correct) and then
a period of griping about how the same questions keep coming up. You
may also like to read the monthly article "Answers to Frequently Asked
Questions" in the newsgroup "news.announce.newusers", which will tell
you what "UNIX" stands for.
With the variety of Unix systems in the world, it's hard to guarantee
that these answers will work everywhere. Read your local manual pages
before trying anything suggested here. If you have suggestions or
corrections for any of these answers, please send them to to
tmatimar@empress.com.
----------------------------------------------------------------------
Subject: Can shells be classified into categories?
>From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
Date: Wed, 7 Oct 92 14:28:18 -0500
5.1) Can shells be classified into categories?
In general there are two main class of shells. The first class
are those shells derived from the Bourne shell which includes sh,
ksh, bash, and zsh. The second class are those shells derived
from C shell and include csh and tcsh. In addition there is rc
which most people consider to be in a "class by itself" although
some people might argue that rc belongs in the Bourne shell class.
With the classification above, using care, it is possible to
write scripts that will work for all the shells from the Bourne
shell category, and write other scripts that will work for all of
the shells from the C shell category.
------------------------------
Subject: How do I "include" one shell script from within another shell script?
>From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
Date: Wed, 7 Oct 92 14:28:18 -0500
5.2) How do I "include" one shell script from within another shell script?
All of the shells from the Bourne shell category (including rc)
use the "." command. All of the shells from the C shell category
use "source".
------------------------------
Subject: Do all shells have aliases? Is there something else that can be used?
>From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
Date: Wed, 7 Oct 92 14:28:18 -0500
5.3) Do all shells have aliases? Is there something else that can be used?
All of the major shells other than sh have aliases, but they
don't all work the same way. For example, some don't accept
arguments.
Although not strictly equivalent, shell functions (which exist in
all shells from the Bourne shell category) have almost the same
functionality of aliases. Shell functions can do things that
aliases can't do.
Use unalias to remove aliases and unset to remove functions.
------------------------------
Subject: How are shell variables assigned?
>From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
Date: Wed, 7 Oct 92 14:28:18 -0500
5.4) How are shell variables assigned?
The shells from the C shell category use "set variable=value" for
variables local to the shell and "setenv variable value" for
environment variables. To get rid of variables in these shells
use unset and unsetenv. The shells from the Bourne shell
category use "variable=value" and may require an "export
VARIABLE_NAME" to place the variable into the environment. To
get rid of the variables use unset.
------------------------------
Subject: How can I tell if I am running an interactive shell?
>From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
>From: dws@ssec.wisc.edu (DaviD W. Sanderson)
Date: Fri, 23 Oct 92 11:59:19 -0600
5.5) How can I tell if I am running an interactive shell?
In the C shell category, look for the variable $prompt.
In the Bourne shell category, you can look for the variable $PS1,
however, it is better to check the variable $-. If $- contains
an 'i', the shell is interactive. Test like so:
case $- in
*i*) # do things for interactive shell
;;
*) # do things for non-interactive shell
;;
esac
------------------------------
Subject: What "dot" files do the various shells use?
>From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
>From: tmb@idiap.ch (Thomas M. Breuel)
Date: Wed, 28 Oct 92 03:30:36 +0100
5.6) What "dot" files do the various shells use?
Although this may not be a complete listing, this provides the
majority of information.
csh
Some versions have system-wide .cshrc and .login files. Every
version puts them in different places.
Start-up (in this order):
.cshrc - always.
.login - login shells.
Upon termination:
.logout - login shells.
Others:
.history - saves the history (based on $savehist).
tcsh
Start-up (in this order):
/etc/csh.cshrc - always.
/etc/csh.login - login shells.
.tcshrc - always.
.cshrc - if no .tcshrc was present.
.login - login shells
Upon termination:
.logout - login shells.
Others:
.history - saves the history (based on $savehist).
.cshdirs - saves the directory stack.
sh
Start-up (in this order):
/etc/profile - login shells.
.profile - login shells.
Upon termination:
any command (or script) specified using the command:
trap "command" 0
ksh
Start-up (in this order):
/etc/profile - login shells.
.profile - login shells.
$ENV - always, if it is set.
Upon termination:
any command (or script) specified using the command:
trap "command" 0
bash
Start-up (in this order):
/etc/profile - login shells.
.bash_profile - login shells.
.profile - login if no .bash_profile is present.
.bashrc - interactive non-login shells.
$ENV - always, if it is set.
Upon termination:
.bash_logout - login shells.
Others:
.inputrc - Readline initialization.
zsh
Start-up (in this order):
.zshenv - always, unless -f is specified.
.zprofile - login shells.
.zshrc - interactive shells, unless -f is specified.
.zlogin - login shells.
Upon termination:
.zlogout - login shells.
rc
Start-up:
.rcrc - login shells
------------------------------
Subject: I would like to know more about the differences ... ?
>From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
Date: Wed, 7 Oct 92 14:28:18 -0500
5.7) I would like to know more about the differences between the
various shells. Is this information available some place?
A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
rc is available via anon. ftp in several places:
cs.uwp.edu (131.210.1.4):pub/vi/shell-100.BetaA.Z
alf.uib.no (129.177.30.3):pub/lpf/misc/shell-100.BetaA.Z
utsun.s.u-tokyo.ac.jp (133.11.11.11):misc/vi/shell-100.BetaA.Z
This file compares the flags, the programming syntax,
input/output redirection, and parameters/shell environment
variables. It doesn't discuss what dot files are used and the
inheritance for environment variables and functions.
------------------------------
End of unix/faq Digest part 5 of 7
**********************************
--
Ted Timar - tmatimar@empress.com
Empress Software, 3100 Steeles Ave E, Markham, Ont., Canada L3R 8T3