HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

c
csh(1) csh(1)
unset commands. Some of the variables are Boolean, that is, the shell does not care what their value is,
only whether they are set or not.
Some operations treat variables numerically. The at sign (@) command permits numeric calculations to be
performed and the result assigned to a variable. The null string is considered to be zero, and any subse-
quent words of multi-word values are ignored.
After the input line is aliased and parsed, and before each command is executed, variable expansion is per-
formed keyed by the dollar sign (
$)character. Variable expansion can be prevented by preceding the
dollar sign with a backslash character (
\
) except within double quotes (") where substitution always
occurs. Variables are never expanded if enclosed in single quotes. Strings quoted by single quotes are
interpreted later (see Command Substitution) so variable substitution does not occur there until later, if at
all. A dollar sign is passed unchanged if followed by a blank, tab, or end-of-line.
Input/output redirections are recognized before variable expansion, and are variable expanded separately.
Otherwise, the command name and entire argument list are expanded together.
Unless enclosed in double quotes or given the
:q modifier, the results of variable substitution may eventu-
ally be command and file name substituted. Within double quotes, a variable whose value consists of multi-
ple words expands to a portion of a single word, with the words of the variables value separated by blanks.
When the
:q modifier is applied to a substitution, the variable expands to multiple words with each word
separated by a blank and quoted to prevent later command or file name substitution.
The following metasequences are provided for introducing variable values into the shell input. Except as
noted, it is an error to reference a variable that is not set.
$variable_name
${variable_name}
When interpreted, this sequence is replaced by the words of the value of the variable
variable_name, each separated by a blank. Braces insulate variable_name from subsequent
characters that would otherwise be interpreted to be part of the variable name itself.
If variable_name is not a
csh variable, but is set in the environment, that value is used.
Non-
csh variables cannot be modified as shown below.
$variable_name[selector]
${variable_name[selector]
}
This modification selects only some of the words from the value of variable_name. The
selector is subjected to variable substitution, and can consist of a single number or two
numbers separated by a dash. The first word of a variable’s value is numbered
1. If the first
number of a range is omitted it defaults to
1. If the last member of a range is omitted it
defaults to the total number of words in the variable ($#variable_name). An asterisk meta-
character used as a selector selects all words.
$#variable_name
${#variable_name}
This form gives the number of words in the variable, and is useful for forms using a [selec-
tor]option.
$0 This form substitutes the name of the file from which command input is being read. An
error occurs if the file name is not known.
$number
${number}
This form is equivalent to an indexed selection from the variable argv ($argv[number]).
$* This is equivalent to selecting all of argv ($argv[*]).
The modifiers :h, :t, :r, :q, and :x can be applied to the substitutions above, as can CR :gh , CR :gt ,
and CR :gr . If curly braces ({}) appear in the command form, the modifiers must appear within the
braces. The current implementation allows only one : modifier on each $d expansion.
The following substitutions cannot be modified with
: modifiers:
$?variable_name
${?variable_name}
Substitutes the string 1 if variable_name is set, 0 if it is not.
$?0 Substitutes 1 if the current input file name is known, 0 if it is not.
$$ Substitutes the (decimal) process number of the (parent) shell.
Section 1140 Hewlett-Packard Company 12 HP-UX 11i Version 1: September 2005