Bug 435398 - $name[selector]:it should fail when any number of 'selector' is out of range
Summary: $name[selector]:it should fail when any number of 'selector' is out of range
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: tcsh
Version: 5.1
Hardware: i686
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Vitezslav Crhonek
QA Contact: Bill Huang
URL:
Whiteboard:
Depends On:
Blocks: 495642 515474
TreeView+ depends on / blocked
 
Reported: 2008-02-29 01:37 UTC by Cai Xianchao
Modified: 2010-01-06 12:26 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 495642 515474 (view as bug list)
Environment:
Last Closed: 2009-01-20 20:33:22 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
This is a patch fixing the bug. (342 bytes, application/octet-stream)
2008-02-29 01:37 UTC, Cai Xianchao
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:0060 0 normal SHIPPED_LIVE tcsh bug fix update 2009-01-20 16:04:02 UTC

Description Cai Xianchao 2008-02-29 01:37:37 UTC
Description of problem:
It fails if the first number of 'selector' is out of range, but not for
the second number when 'selector' is composed of two numbers. 

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

How reproducible:


Steps to Reproduce:
1.set test=(ab cd) 
2.echo $test[3-1] 
3.echo $?
  
Actual results:
Only blank line is outputed and the return value is 0.

Expected results:
Error message 'out of range' is outputed and the return value is not 0.

Additional info:

Comment 1 Cai Xianchao 2008-02-29 01:37:37 UTC
Created attachment 296297 [details]
This is a patch fixing the bug.

Comment 2 Vitezslav Crhonek 2008-02-29 12:52:45 UTC
Thanks for report and patch!
Fixed in Fedora rawhide.

Comment 3 RHEL Program Management 2008-06-02 20:16:24 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 8 errata-xmlrpc 2009-01-20 20:33:22 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-0060.html

Comment 9 Sam Hart 2009-04-10 01:42:53 UTC
This patch effectively breaks expected functionality in tcsh.

Running the following script produces "argv: Subscript out of range."

#!/bin/tcsh -f
echo $argv[1-]

In the tcsh manual : http://www.tcsh.org/tcsh.html/Variable_substitution.html

$name[selector]

${name[selector]}
Substitutes only the selected words from the value of name. The selector is subjected to `$' substitution and may consist of a single number or two numbers separated by a `-'. The first word of a variable's value is numbered `1'. If the first number of a range is omitted it defaults to `1'. If the last member of a range is omitted it defaults to `$#name'. The selector `*' selects all words. It is not an error for a range to be empty if the second argument is omitted or in range.

It's the last sentence that makes the difference here. The same behaviour is seen in csh. 

The patch removes a condition that appears to be deliberate.

Comment 10 Joe Wells 2009-08-04 10:13:17 UTC
(In reply to comment #1)

You have broken a documented feature!  $foo[2-] or $foo[2-1] is documented to return zero words even if $foo[2] is undefined.  This is important, and lots of tcsh scripts around the world depend on it continuing to work.

Can you please urgently revert this change and release an update?

Thanks in advance for undoing your breaking of vital tcsh functionality!

Comment 11 Sam Hart 2009-08-04 18:18:19 UTC
Joe, have a look at https://bugzilla.redhat.com/show_bug.cgi?id=495642 they've agreed to revert the patch in 5.5, though I am personally glad someone else picked up on this.


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