Same as cmd.exe: a file reference + arguments. Examples:
notepad hello.txt
cp hello.* a:Individual statements are parsed into a series of words separated by white space (spaces or tabs) or these special tokens:
& | ; > < ( ) && || >> << >& >! >&!
Wildcarding is done by the shell before invoking the child.
Under OS/2, up to 64K of environmental and 64K of command-line argument data can be passed to a child process.
Under Windows NT or Windows 95, up to 32K of command-line data can be passed. These are the limits of the kernels, not the C shell; there is no limit on overall command line length in the C shell itself.
Hamilton C shell maintains a hash structure which allows it to quickly search for a suitable .csh, .exe, .com, .cmd or .bat file (on OS/2 2.x, Windows NT or Windows 95) in that order in each of as many as 256 path directories.
Hamilton C shell provides both if and switch constructs. The if statement comes in both short and long forms. The long form uses a then keyword and allows an optional else clause.
if ( expr ) then
statement_list
else
statement_list
endif ( expr ) then
statement_list
endThe short form, which must be typed on one line, dispenses with the then keyword and accepts a single statement to be executed if the condition is satisfied.
if ( expr ) statement
Where an expression is expected, a conventional high level language syntax is accepted: e.g., names refer to variables, "*" means multiply, not wildcard and ">" means greater than, not i/o redirection.
if statements can also be chained using the elif keyword. The last if in the chain may be either a short- or a long-form if statement.
if ( expr ) then
statement_list
elif ( expr ) then
statement_list
else
statement_list
endif ( expr ) then
statement_list
elif ( expr ) then
statement_list
endif ( expr ) then
statement_list
elif ( expr ) statementIn a switch statement, expressions are compared by pattern match: the case expression can be a string with wildcard characters. Comparisons are made down the list of alternatives until one matches. All following statements are executed until a break is encountered. A default clause is optional but is always satisfied if no other case matches.
switch ( expr )
case expr:
statement_list
case expr:
statement_list
default:
statement_list
end
The foreach statement is intended for iteration over a list of words, often specified by
foreach name ( wordlist )
statement_list
endThe for statement offers the more conventional numeric iteration. Multiple iteration ranges, separated by commas, can be specified on the for statement.
for name = expr [ to expr ] [ by expr ] do
statement_list
endThe while statement iterates so long as the control expression continues to evaluate as non-zero.
while ( expr )
statement_list
endThe repeat statement has two variations. The first provides for the iteration of a single statement an integer number of times.
repeat number statement
The second form of the repeat iterates until the control expression evaluates as non-zero, allowing it to exit.
repeat
statement_list
until ( expr )
Procedures defined by the proc statement can recursively call other procedures. They can be referred to inside an expression or as a new command, in which case any value returned is written to stdout. There is an implicit return statement at the end of every procedure definition.
proc name ( [ namelist ] )
statement_list
return [ expr ]
endThe proc statement with no arguments prints a list of all the procedures that have been defined; if the argument is a name, that one procedure is listed; if the argument is a pattern, all procedures whose names match the pattern are listed.
proc
proc name
proc patternunproc namelist (where namelist is a series of names separated by commas) discards the specified procedures. unproc pattern discards all procedures whose names match the pattern are discarded.
unproc namelist
unproc pattern
Aliases provide a way of conveniently recalling frequently used commands with a user-defined shorthand name. The alias statement associates a list of words with an alias name. The "=" is optional. Parentheses are used around the wordlist if it contains special characters such as i/o redirection operators that should be part of the alias definition.
alias name [ = ] ( wordlist )
alias name [ = ] wordlistalias name prints the definition of that alias; alias pattern prints the definitions of all the aliases whose names match the pattern. alias without any arguments prints the definitions of all the aliases.
alias
alias name
alias patternunalias namelist discards the specified aliases; unalias pattern discards all the aliases whose names match the pattern.
unalias namelist
unalias pattern
The @ and calc statements will each calculate the value of an expression; the @ statement does it silently while the calc statement writes the result to stdout.
@ expr
calc exprThe set, setenv and shift statements manipulate variables as words rather than expressions. set defines a variable that's shared between all threads in the shell; setenv puts it into the environment which is inherited by child processes.
set named_ref [ = ] ( wordlist )
set named_ref [ = ] wordlist
setenv named_ref [ = ] ( wordlist )
setenv named_ref [ = ] wordlist
shift [ name ]set or setenv with no operands prints a list of all defined variables of that type. set name or setenv name with no arguments prints the value of the named variable. set pattern or setenv pattern prints the values of all the variables whose names match the pattern. To resolve the ambiguity between a pattern and an indexed variable reference, pattern arguments to set or setenv cannot use the "[" as the first wildcard character in the string.
set
set name
set pattern
setenv
setenv name
setenv patternunset namelist or unsetenv namelist discard the specified variables. unset pattern or unsetenv pattern discard all the shell or environment variables, respectively, that match the pattern.
unset namelist
unset pattern
unsetenv namelist
unsetenv pattern(Under Windows NT and Windows 95, environment variable names are case-insensitive, so any patterns used with setenv or unsetenv are also considered case-insensitive.)
The local command lets you define a list of variable names that you don't to share with other routines or other processes or threads (except your own child threads). When you define a local variable it hides any previous definition from any outer statement list. (But you are not permitted to redefine any of the built-in set or setenv variable names.)
local namelist
local
local patternThe namelist should be typed with commas between the names. When you create a new local variable, its initial value is always a null string. local with no operands reports the currently defined and accessible local variables, if any. local pattern lists all the local variables whose names match the pattern.
When you spawn a child thread either implicitly, e.g., to run the second or following stage of a pipeline or explicitly, by typing an ampersand at the end of a command to run it in the background all your current local variables are snapshotted and copied to the child. If, following that, either the parent or the child changes the value of any of these local variables, it affects only its own copy.
Local variables are automatically discarded as soon as execution leaves the statement nesting level in which the variable was created. You can also explicitly discard local variables using the unlocal command.
unlocal namelist
unlocal patternunlocal namelist discards the specified local variables. unlocal pattern discards all those whose names match the pattern.
In all other respects, local variables act just like any other variables, though you may find they're slightly faster since the shell doesn't need to semaphore its use of them.
Next Topic
Hamilton C shell |
Free Updates |
Free Demo Software |
Win32 Training
Y2K |
Customer Testimonials |
On-line Hamilton C shell User Guide
Home |
Email |
Support |
Company Profile |
Distributors |
Links
Copyright © 1997-2001 by Hamilton Laboratories. All rights reserved.
You are visitor number
2408.
This page was last modified August 9, 2001.