#573457 csh: failure in switch statement

Package:
csh
Source:
csh
Description:
Shell with C-like syntax
Submitter:
Xin Wu
Date:
2010-06-20 23:00:08 UTC
Severity:
normal
#573457#5
Date:
2010-03-11 16:20:26 UTC
From:
To:
The problem is described below:

On this system, there is a simple C shell script named "test.csh".

xwu@debian:~$ cat test.csh
#!/bin/csh
set FC=ifort
switch ($FC)
   case ifort:
# This is the expected case, which displays "ifort" on stdout.
     echo $FC
     breaksw
   default:
     echo "a bug here?"
     exit 4
endsw
xwu@debian:~$ chmod 755 test.csh
xwu@debian:~$ ./test.csh
a bug here?

On some other *NIX systems, the expected string "ifort" can be shown.

Best regards,

Xin Wu

#573457#10
Date:
2010-03-18 22:57:28 UTC
From:
To:
I had a quick look at this RC bug:

The token 'ifort:' after the 'case' keyword starts with 'if'.
Because of this, the getword() function in func.c stops scanning
premature. The same would happen if the token starts with 'while' or
'switch'.
The comment at the top of the keyword() function may help to solve the
problem.

If the string is quoted, everything works, e.g.:
 case "ifort":

Best wishes
 Johann Felix Soden