[10096] in Athena Bugs
decmips 7.4G: csh programming considered harmful
daemon@ATHENA.MIT.EDU (Calvin Clark)
Wed Nov 25 11:45:19 1992
Date: Wed, 25 Nov 92 11:44:55 -0500
From: Calvin Clark <ckclark@mit.edu>
To: bugs@Athena.MIT.EDU
Cc: bug-tcsh6@Athena.MIT.EDU
Reply-To: ckclark@mit.edu
System name: podge
Type and version: KN01 7.4G
Display type: PMAX-MFB
What were you trying to do?
Demonstrate the fanatastic brokenness of csh (and test its
hashing compared to other shells.) This bug report applies to /bin/csh
(/bin/athena/tcsh) on the DECstation and to the following Cornell tcsh
versions:
tcsh 6.02.00 (Cornell) 92/05/15 options 8b,dl
tcsh 6.02.07 (Cornell) 92/09/17 (decmips) options 8b,dl
What's wrong:
The following script loops forever:
#!/bin/csh -f
set count = 0
while ($status == 0)
set count = `expr $count + 1`
echo "count is: $count"
test $count -lt 3
end
as does this simpler script:
#!/bin/csh -f
while ($status == 0)
echo "status is $status"
/bin/false
end
And this script prints the output "status is 0" and
terminates. This script indicates best where the
problem lies:
#!/bin/csh -f
/bin/false
while ($status == 1)
echo "status is $status"
/bin/false
end
The essential problem here is that the "while" test is setting status to
0, when it shouldn't. This is inconsistent with the behavior of the if
statement:
; /bin/csh -f
% /bin/false
% if ($status == 1) echo $status
1
Please look at the last "while" example again, and think about it. More
than one thing is wrong.
What should have happened:
Csh should have sane and predictable behavior. NOT!
Please describe any relevant documentation references:
csh(1), Regular posting of "csh.whynot" to comp.unix.shell,
available by:
attach -n -e rtfm:/ua
cd /rtfm/ua/ftp/pub/usenet/comp.unix.shells
zcat Csh_Programming_Considered_Harmful.Z | more
(You can get it by anonymous ftp to rtfm.mit.edu, too.)
If marc agrees that this is a bug, I will send it in to Tom
Christiansen for inclusion in his rant. :-)