Agreeing with comment by @mark-plotnick@mark-plotnick, OP has to ensure that the script is run by csh, e.g., by adding the "hash-bang" line:
#!/bin/csh
or running the script using the appropriate program:
csh ./foo
As a general rule, if a script lacks this information it will be run using /bin/sh
Further reading:
- The #! magic, details about the shebang/hash-bang mechanism on various Unix flavours
- 3.16) Why do some scripts start with #! ... ? Unix - Frequently Asked Questions (3/7)