Re: tcsh bug
- From: "Icarus Sparry" <usenet@xxxxxxxxxxxxxxxxx>
- Date: 28 Sep 2006 13:52:52 GMT
On Thu, 28 Sep 2006 06:31:20 -0700, blue wrote:
#! /bin/tcsh -f
# tcsh 6.12.00
if (-e Hce.res) then
fgrep PASSED Hce.res >& /dev/null
if ($status)then
# If you put a space between "($status)" and "then" things work fine.
echo "Hce.res exists:: FAIL1: HCE "
else
echo "Hce.res exists:: PASS2: HCE Test"
endif
else
echo "Hce.res does NOT exist:: FAIL3: "
endif
The problem as you note is your second "if" statement, the lack of a space
following the ")" means that it is not recognized as an "if" by the tcsh
pattern recognizer. Hence the first "else" is paired with the first "if",
and you get the output from the second "echo" if the file does not exist.
So the bug is the lack of warnings from the second "else" and the second
"endif".
More proof, if any was needed, that parsing your input, as "sh" and "rc"
family shells do, is superior to ad-hoc pattern matching. Hence the
usual advice to not use csh (or tcsh) for scripts.
.
- References:
- tcsh bug
- From: blue
- tcsh bug
- Prev by Date: Re: tcsh bug
- Next by Date: Re: duplicate entries - compare files
- Previous by thread: Re: tcsh bug
- Index(es):
Relevant Pages
|