[comp.unix.shell] C-Shell Question

athos@apple.com (Rick Eames) (11/22/90)

I am having a problem with a shell script that really does nothing, but 
won't work anyway.

set x=1
set y=10

while ($x <=$y)
     echo This does nothing.
     @ x++
end


when I run this script, it tells me that it didn't expect an end of file, 
and get's the error one line greater than the actual number of lines in 
the file.

Any hints?

please respond to athos@apple.com


###########################
Athos
"Not Apple's Opinions....blah...blah....blah"

yeates@motcid.UUCP (Tony J Yeates) (11/30/90)

athos@apple.com (Rick Eames) writes:

>I am having a problem with a shell script that really does nothing, but 
>won't work anyway.

>set x=1
>set y=10

>while ($x <=$y)
>     echo This does nothing.
>     @ x++
>end


>when I run this script, it tells me that it didn't expect an end of file, 
>and get's the error one line greater than the actual number of lines in 
>the file.

Don't know why it fails, but it does  in csh & tcsh .... usually!
If you do:

	csh <script name>

it works! (You need to add a space between the >= and the $y tho')

The fix is to add the shell selection line at the start, on the Sun I work
on, my first line is "#!/bin/csh -f". Works fine! (Again don't know why -
is it a bug, or are we missing something here?!)

I think you should prob. use @ x = 1 and @ y = 10, rather than "set" -
although it works without them.

This seems like a black art sometimes!