Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
C shell
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Expressions === The C shell implements a 32-bit integer expression grammar with operators borrowed from C but with a few additional operators for string comparisons and filesystem tests, e.g., testing for the existence of a file. Operators must be separated by whitespace from their operands. Variables are referenced as <code>$</code>''name''. [[Operator precedence#Programming languages|Operator precedence]] is also borrowed from C, but with different [[operator associativity]] rules to resolve the ambiguity of what comes first in a sequence of equal precedence operators. In C, the associativity is left-to-right for most operators; in C shell, it is right-to-left. For example, {{column |width=60em |1= <syntaxhighlight lang="c"> // C groups from the left int i = 10 / 5 * 2; printf( "%d\n", i ); // prints 4 i = 7 - 4 + 2; printf( "%d\n", i ); // prints 5 i = 2 >> 1 << 4; printf( "%d\n", i ); // prints 16 </syntaxhighlight> |2= <syntaxhighlight lang="csh"> # C shell groups from the right @ i = 10 / 5 * 2 echo $i # prints 1 @ i = 7 - 4 + 2 echo $i # prints 1 @ i = ( 2 >> 1 << 4 ) echo $i # prints 0 </syntaxhighlight> }} The parentheses in the C shell example are to avoid having the bit-shifting operators confused as I/O redirection operators. In either language, parentheses can always be used to explicitly specify the desired order of evaluation, even if only for clarity. Return values are limited to 8-bit. For <code>exit</code> expressions, the unary negation operator can be used for 32-bit evaluation. <syntaxhighlight lang="csh"> exit ! ! 256 # Returns 1. </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
C shell
(section)
Add topic