Introduction

Introduction

The tc shell is an enhanced but completely compatible version of the Berkeley C shell. Its two most common uses are as an interactive run time environment and as an interpreter of shell scripts.

The term "login shell" is used to distinguish the shell invoked by the OS for a user at login time from a shell invoked from the command line of an existing login session or perhaps as part of the execution of a shell script.

Sourcing vs. Execution

An important distinction in shell scripting are the concepts of sourcing and execution. When you execute a process (such as a shell script) the shell spawns a child process to run the commands contained therein. When the child process terminates, any changes to environment variables are lost. Sourcing, by contrast, does not spawn a child process, but rather treats the commands contained in the shell script as if they were input from the keyboard. Thus, any changes to your environment made in the script are retained by the login shell. For that reason, configuration files should be sourced, not executed. To source, the following command is used:

source .alias

As with the bash shell, the commands in this chapter are formatted in a way a bit different from standard. There are 12 sections in this chapter, each covering a different TC shell topic:

Command Line Options

Startup and Shutdown

Command Line Editor

Command Completion

Command History

Filename Substitution

The Directory Stack

Process Control and Scheduling

Aliases

Shell Scripting

Terminal Control

Miscellaneous Commands

Related Files

/etc/csh.cshrc

Systemwide initialization file read first by every instance of the TC shell. Typically used to set systemwide environment variables and run universal startup scripts. Note that this file is read by login and nonlogin shells alike.

/etc/csh.login

If tcsh is your login shell (as opposed to a shell invoked from the command line, or perhaps as part of a script), this file will be read after csh.cshrc.

~/.tcshrc

Read by every shell after /etc/csh.cshrc or its equivalent. Contains user-specific startup commands. Typically this file is used to set the environment and invoke startup scripts.

~/.cshrc

If ~/.tcshrc does not exist, this file will be read instead.

~/.history

If savehist shell variable is set, this file will be read by login shells after ~/.tcshrc. This file contains a record of the commands that have been run by the user.

~/.login

By default this file is read by login shells after ~/.tcshrc or ~/.history. This file is designed to contain commands like stty, which need to be run only once per login session.

~/.cshdirs

Read by login shells after ~/.login if savedirs is set.

/etc/csh.logout

Read by login shells at logout.

~/.logout

Read by login shells at logout after /etc/csh.logout or its equivalent.

/bin/sh

Used to interpret shell scripts not starting with a '#'.

/tmp/sh*

Temporary file for '<<'.

/etc/passwd

Specifies login shell, also source for home directories for '~name' substitution.

Note that the order in which the startup files are considered can be changed from the defaults at the time it is compiled.

 



Linux Desk Reference
Linux Desk Reference (2nd Edition)
ISBN: 0130619892
EAN: 2147483647
Year: 2000
Pages: 174
Authors: Scott Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net