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 subsequent words of
After the input line is aliased and parsed, and before each command is executed, variable expansion is performed 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
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 modi®er, the results of variable substitution may eventually be command and ®le name substituted. Within double quotes, a variable whose value consists of multiple words expands to a portion of a single word, with the words of the variable's value separated by blanks. When the :q modi®er 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 ®le 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.
$variable_name[selector]
${variable_name[selector]}
This modi®cation 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 ®rst word of a variable's value is numbered 1. If the ®rst 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 [selector ] option.
$0 This form substitutes the name of the ®le from which command input is being read. An error occurs if the ®le 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 modi®ers :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 modi®ers must appear within the braces. The current implementation allows only one : modi®er on each $d expansion.
The following substitutions cannot be modi®ed with : modi®ers:
$?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 ®le name is known, 0 if it is not.
$$ Substitutes the (decimal) process number of the (parent) shell.
Section 1−140 | − 12 − |