Bug 436072

Summary: "command" can be a command list in builtin "if"
Product: Red Hat Enterprise Linux 5 Reporter: Cai Xianchao <caixianchao>
Component: tcshAssignee: Vitezslav Crhonek <vcrhonek>
Status: CLOSED NOTABUG QA Contact: Bill Huang <bhuang>
Severity: low Docs Contact:
Priority: low    
Version: 5.1   
Target Milestone: rc   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-03-05 11:16:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
This is a patch fixing the bug. none

Description Cai Xianchao 2008-03-05 07:48:27 UTC
Description of problem:

The manpage says that "command must  be  a  simple  command,  not  an alias,  a
 pipeline,  a command list or a parenthesized command list, but it  may  have 
arguments.", but "command" can be a command list.

Version-Release number of selected component (if applicable):
tcsh-6.15.00

How reproducible:


Steps to Reproduce:
1.[test@localhost ~]$ ls
test

2.[test@localhost ~]$ pwd
/home/test

3.[test@localhost ~]$ if (1) ls;pwd
test
/home/test

  
Actual results:
The command 'ls' and 'pwd' both are executed correctly.

Expected results:
There is a error outputed or only one command is executed.

Additional info:

Comment 1 Cai Xianchao 2008-03-05 07:48:27 UTC
Created attachment 296861 [details]
This is a patch fixing the bug.

Comment 2 Vitezslav Crhonek 2008-03-05 11:16:32 UTC
Try:

[test@localhost ~]$ if (0) ls;pwd
/home/test

The second command does have nothing to do with the 'if' statement.

Comment 3 Cai Xianchao 2008-03-06 00:56:35 UTC
I see.

The tcsh regards 'if (0) ls;pwd' as two commands, 'if (0) ls' and 'pwd'.

Actually, when I saw something like 'command must  be  a  simple  command', I
thought it would fail and the exit code would be not 0 if 'command is not a
simple command'. 

Thanks for your example.