HP-UX Reference (11i v2 03/08) - 1 User Commands A-M (vol 1)
c
csh(1) csh(1)
Also available in expressions as primitive operands are command executions enclosed in curly braces
( {}) and file enquiries of the form
-l filename, where l is one of:
r read access
w write access
x execute access
e existence
o ownership
z zero size
f plain file
d directory
The specified filename is command- and file-name expanded then tested to see if it has the specified rela-
tionship to the real user. If the file does not exist or is inaccessible, all inquiries return false (0). Com-
mand executions succeed, returning true, if the command exits with status 0; otherwise they fail, return-
ing false. If more detailed status information is required, the command should be executed outside of an
expression and the
status variable examined.
Control of the Flow
csh contains a number of commands that can be used to regulate the flow of control in command files
(shell scripts) and (in limited but useful ways) from terminal input. These commands all operate by forc-
ing the shell to reread or skip parts of its input and, due to the implementation, restrict the placement of
some of the commands.
The
foreach, switch, and while statements, as well as the if-then-
else form of the if state-
ment require that the major keywords appear in a single simple command on an input line as shown
below.
If the shell’s input is not seekable, the shell buffers input whenever a loop is being read and performs
seeks in this internal buffer to accomplish the rereading implied by the loop. (To the extent that this
allows, backward
gotos succeed on non-seekable inputs.)
Signal Handling
csh normally ignores quit signals. Jobs running in background mode are immune to signals generated
from the keyboard, including hangups. Other signals have the values which the shell inherited from its
parent. csh’s handling of interrupts and terminate signals in shell scripts can be controlled by onintr.
Login shells catch the terminate signal; otherwise this signal is passed on to children from the state in the
shell’s parent. In no case are interrupts allowed when a login shell is reading the file
.logout.
Command Line Parsing
csh splits input lines into words at blanks and tabs. The following exceptions (parser metacharacters)
are considered separate words:
& ampersand;
| vertical bar;
; semicolon;
< less-than sign;
> greater-than sign;
( left parenthesis;
) right parenthesis;
&& double ampersand;
|| double vertical bar;
<< double less-than sign;
>> double greater-than sign;
# comment delimiter
The backslash (
\) removes the special meaning of these parser metacharacters. A parser metacharacter
preceded by a backslash is interpreted as its ASCII value. A newline character (ASCII 10) preceded by a
backslash is equivalent to a blank.
Strings enclosed in single or double quotes form parts of a word. Metacharacters in these strings, includ-
ing blanks and tabs, do not form separate words. Within pairs of backslashes or quotes, a newline pre-
ceded by a backslash gives a true newline character.
When
csh’s input is not a terminal, the # character introduces a comment terminated by a newline.
Section 1−−140 Hewlett-Packard Company − 11 − HP-UX 11i Version 2: August 2003