Bug 5338 - tcsh && is not short circuiting
tcsh && is not short circuiting
Product: Red Hat Linux
Classification: Retired
Component: tcsh (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Nalin Dahyabhai
Depends On:
  Show dependency treegraph
Reported: 1999-09-23 16:26 EDT by jfoster
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-03-25 00:38:22 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description jfoster 1999-09-23 16:26:07 EDT
Running the following script yields the error "X11:
Undefined variable," whereas it should exit normally.


unsetenv X11
if ($?X11 && ($X11 == "huh?")) then
   echo "a"
echo "b"
Comment 1 Jeff Johnson 2000-01-10 15:48:59 EST
This bug is still present in tcsh-6.09-1.
Comment 2 Göran Uddeborg 2001-07-17 17:30:25 EDT
This is not a bug, is it?  Variable expansion takes place in one step for a
complete line, before any evaluation of the expression or execution of command. 
As far as I'm aware, it has always been necessary to do

if ($?X11) then
   if ($X11 == "huh?") then
      echo "a"

to achieve the desired effect.  Both in tcsh and in the original csh.
Comment 3 jfoster 2001-07-17 18:40:06 EDT
OK, it's a feature then.
Comment 4 Ben Liblit 2001-07-17 20:12:15 EDT
The reported behavior is surprising but correct.  Read "Csh Programming
Considered Harmful", section 6 (Expression Evaluation). 

Note You need to log in before you can comment on or make changes to this bug.