Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
110
Lang/C-Shell/00-LANG.txt
Normal file
110
Lang/C-Shell/00-LANG.txt
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
{{language
|
||||
|exec=interpreted
|
||||
|tags=csh
|
||||
|hopl id=1936
|
||||
}}{{implementation|UNIX Shell}}
|
||||
'''csh''' was the shell that William Joy wrote for [[BSD]]. '''csh''' accepted the same [[Unix]] commands as other shells, but had a very different syntax (for variable assignments, control flow, and such). '''csh''' is not compatible with the [[Bourne Shell]].
|
||||
|
||||
BSD keeps the C Shell at <code>/bin/csh</code>. [[Hashbang]] lines should use the -f option:
|
||||
|
||||
<lang csh>#!/bin/csh -f</lang>
|
||||
|
||||
== Reputation ==
|
||||
C Shell is obsolete. Most scriptwriters prefer a Bourne-compatible shell, and few users want to learn two flavors of shells. C Shell introduced tilde expansion (<code>ls ~</code>), job control, command history, and aliases, but POSIX shells now have all of those.
|
||||
|
||||
[http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ Csh Programming Considered Harmful] and [http://www.grymoire.com/Unix/CshTop10.txt Top Ten Reasons not to use the C shell] give multiple reasons to avoid C Shell.
|
||||
|
||||
tcsh is a later version that fixed many of the problems with csh. It is still actively, if intermittently, maintained and has a following such as on Solaris.
|
||||
|
||||
== Syntax ==
|
||||
[http://www.openbsd.org/cgi-bin/man.cgi?query=csh&apropos=0&sektion=1&manpath=OpenBSD+Current&arch=i386&format=html The manual for csh(1)] claims that C Shell has "a C-like syntax". Several other languages have a C-like syntax, including [[Java]] and [[Pike]], and Unix utilities [[AWK]] and [[bc]]. C Shell is less like [[C]] than those other languages.
|
||||
|
||||
This example prints a [[Hailstone sequence]] from 13.
|
||||
|
||||
{| class="wikitable"
|
||||
! C
|
||||
! C Shell
|
||||
|-
|
||||
|| <lang c>#include <stdio.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int n;
|
||||
|
||||
n = 13;
|
||||
printf("%d\n", n);
|
||||
while (n != 1) {
|
||||
if (n % 2)
|
||||
n = 3 * n + 1;
|
||||
else
|
||||
n /= 2;
|
||||
|
||||
printf("%d\n", n);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}</lang>
|
||||
|| <lang csh>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ n = 13
|
||||
echo $n
|
||||
while ($n != 1)
|
||||
if ($n % 2) then
|
||||
@ n = 3 * $n + 1
|
||||
else
|
||||
@ n /= 2
|
||||
endif
|
||||
echo $n
|
||||
end
|
||||
|
||||
|
||||
</lang>
|
||||
|}
|
||||
|
||||
C Shell has no braces {} to group the commands. Strange keywords are <code>then</code>, <code>endif</code> and <code>end</code>. Expressions have <code>$n</code> instead of <code>n</code>. Assignments use <code>@ n</code>.
|
||||
|
||||
C Shell has "a C-like syntax" because C Shell is more like C than [[Bourne Shell]].
|
||||
|
||||
{| class="wikitable"
|
||||
! Bourne Shell
|
||||
! C Shell
|
||||
|-
|
||||
|| <lang bash>n=13
|
||||
echo $n
|
||||
while test $n -ne 1; do
|
||||
if expr $n % 2 >/dev/null; then
|
||||
n=`expr 3 \* $n + 1`
|
||||
else
|
||||
n=`expr $n / 2`
|
||||
fi
|
||||
echo $n
|
||||
done</lang>
|
||||
|| <lang csh>@ n = 13
|
||||
echo $n
|
||||
while ($n != 1)
|
||||
if ($n % 2) then
|
||||
@ n = 3 * $n + 1
|
||||
else
|
||||
@ n /= 2
|
||||
endif
|
||||
echo $n
|
||||
end</lang>
|
||||
|}
|
||||
|
||||
Bourne Shell requires <code>test</code> or <code>expr</code> to evaluate expressions. C Shell has built-in expressions, so the Hailstone sequence comes more easily. These expressions have a stupid quirk: all operators are right-associative, so <code>10 - 3 - 2</code> acts like <code>10 - (3 - 2)</code>. The fix is to use parentheses.
|
||||
|
||||
<lang csh>% @ n = 10 - 3 - 2
|
||||
% echo $n
|
||||
9
|
||||
% @ n = (10 - 3) - 2
|
||||
% echo $n
|
||||
5</lang>
|
||||
|
||||
== Links ==
|
||||
* [[OpenBSD]] has [http://www.openbsd.org/cgi-bin/man.cgi?query=csh&apropos=0&sektion=1&manpath=OpenBSD+Current&arch=i386&format=html csh(1) manual] and [http://www.openbsd.org/cgi-bin/cvsweb/src/bin/csh/ source code].
|
||||
2
Lang/C-Shell/00-META.yaml
Normal file
2
Lang/C-Shell/00-META.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Category:C_Shell
|
||||
1
Lang/C-Shell/A+B
Symbolic link
1
Lang/C-Shell/A+B
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/A+B/C-Shell
|
||||
1
Lang/C-Shell/Comments
Symbolic link
1
Lang/C-Shell/Comments
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Comments/C-Shell
|
||||
1
Lang/C-Shell/Conditional-structures
Symbolic link
1
Lang/C-Shell/Conditional-structures
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Conditional-structures/C-Shell
|
||||
1
Lang/C-Shell/Enforced-immutability
Symbolic link
1
Lang/C-Shell/Enforced-immutability
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Enforced-immutability/C-Shell
|
||||
1
Lang/C-Shell/Ethiopian-multiplication
Symbolic link
1
Lang/C-Shell/Ethiopian-multiplication
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Ethiopian-multiplication/C-Shell
|
||||
1
Lang/C-Shell/Execute-a-system-command
Symbolic link
1
Lang/C-Shell/Execute-a-system-command
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Execute-a-system-command/C-Shell
|
||||
1
Lang/C-Shell/Factorial
Symbolic link
1
Lang/C-Shell/Factorial
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Factorial/C-Shell
|
||||
1
Lang/C-Shell/FizzBuzz
Symbolic link
1
Lang/C-Shell/FizzBuzz
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/FizzBuzz/C-Shell
|
||||
1
Lang/C-Shell/Greatest-common-divisor
Symbolic link
1
Lang/C-Shell/Greatest-common-divisor
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Greatest-common-divisor/C-Shell
|
||||
1
Lang/C-Shell/Guess-the-number
Symbolic link
1
Lang/C-Shell/Guess-the-number
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Guess-the-number/C-Shell
|
||||
1
Lang/C-Shell/Hailstone-sequence
Symbolic link
1
Lang/C-Shell/Hailstone-sequence
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Hailstone-sequence/C-Shell
|
||||
1
Lang/C-Shell/Hello-world-Newline-omission
Symbolic link
1
Lang/C-Shell/Hello-world-Newline-omission
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Hello-world-Newline-omission/C-Shell
|
||||
1
Lang/C-Shell/Hello-world-Standard-error
Symbolic link
1
Lang/C-Shell/Hello-world-Standard-error
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Hello-world-Standard-error/C-Shell
|
||||
1
Lang/C-Shell/Hello-world-Text
Symbolic link
1
Lang/C-Shell/Hello-world-Text
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Hello-world-Text/C-Shell
|
||||
1
Lang/C-Shell/Here-document
Symbolic link
1
Lang/C-Shell/Here-document
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Here-document/C-Shell
|
||||
1
Lang/C-Shell/Include-a-file
Symbolic link
1
Lang/C-Shell/Include-a-file
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Include-a-file/C-Shell
|
||||
1
Lang/C-Shell/Increment-a-numerical-string
Symbolic link
1
Lang/C-Shell/Increment-a-numerical-string
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Increment-a-numerical-string/C-Shell
|
||||
1
Lang/C-Shell/Interactive-programming-repl-
Symbolic link
1
Lang/C-Shell/Interactive-programming-repl-
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Interactive-programming-repl-/C-Shell
|
||||
1
Lang/C-Shell/Least-common-multiple
Symbolic link
1
Lang/C-Shell/Least-common-multiple
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Least-common-multiple/C-Shell
|
||||
1
Lang/C-Shell/Loop-over-multiple-arrays-simultaneously
Symbolic link
1
Lang/C-Shell/Loop-over-multiple-arrays-simultaneously
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Loop-over-multiple-arrays-simultaneously/C-Shell
|
||||
1
Lang/C-Shell/Loops-For
Symbolic link
1
Lang/C-Shell/Loops-For
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Loops-For/C-Shell
|
||||
1
Lang/C-Shell/Loops-For-with-a-specified-step
Symbolic link
1
Lang/C-Shell/Loops-For-with-a-specified-step
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Loops-For-with-a-specified-step/C-Shell
|
||||
1
Lang/C-Shell/Loops-Foreach
Symbolic link
1
Lang/C-Shell/Loops-Foreach
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Loops-Foreach/C-Shell
|
||||
1
Lang/C-Shell/Loops-Infinite
Symbolic link
1
Lang/C-Shell/Loops-Infinite
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Loops-Infinite/C-Shell
|
||||
1
Lang/C-Shell/Shell-one-liner
Symbolic link
1
Lang/C-Shell/Shell-one-liner
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Shell-one-liner/C-Shell
|
||||
1
Lang/C-Shell/Short-circuit-evaluation
Symbolic link
1
Lang/C-Shell/Short-circuit-evaluation
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Short-circuit-evaluation/C-Shell
|
||||
1
Lang/C-Shell/Sieve-of-Eratosthenes
Symbolic link
1
Lang/C-Shell/Sieve-of-Eratosthenes
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Sieve-of-Eratosthenes/C-Shell
|
||||
1
Lang/C-Shell/Spinning-rod-animation-Text
Symbolic link
1
Lang/C-Shell/Spinning-rod-animation-Text
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Spinning-rod-animation-Text/C-Shell
|
||||
1
Lang/C-Shell/String-interpolation-included-
Symbolic link
1
Lang/C-Shell/String-interpolation-included-
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/String-interpolation-included-/C-Shell
|
||||
1
Lang/C-Shell/Terminal-control-Dimensions
Symbolic link
1
Lang/C-Shell/Terminal-control-Dimensions
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Terminal-control-Dimensions/C-Shell
|
||||
1
Lang/C-Shell/Terminal-control-Inverse-video
Symbolic link
1
Lang/C-Shell/Terminal-control-Inverse-video
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../Task/Terminal-control-Inverse-video/C-Shell
|
||||
Loading…
Add table
Add a link
Reference in a new issue