Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 5338 - tcsh && is not short circuiting
Summary: tcsh && is not short circuiting
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: tcsh
Version: 6.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Nalin Dahyabhai
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 1999-09-23 20:26 UTC by jfoster
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2002-03-25 05:38:22 UTC

Attachments (Terms of Use)

Description jfoster 1999-09-23 20:26:07 UTC
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 20:48:59 UTC
This bug is still present in tcsh-6.09-1.

Comment 2 Göran Uddeborg 2001-07-17 21:30:25 UTC
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 22:40:06 UTC
OK, it's a feature then.

Comment 4 Ben Liblit 2001-07-18 00:12:15 UTC
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.