Bug 515474 - $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 DUPLICATE of bug 495642
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: tcsh
Version: 5.3
Hardware: i686
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Vitezslav Crhonek
QA Contact: BaseOS QE
URL:
Whiteboard:
Depends On: 435398
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-08-04 13:40 UTC by Chris Ward
Modified: 2009-08-05 11:53 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 435398
Environment:
Last Closed: 2009-08-05 11:53:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Chris Ward 2009-08-04 13:40:33 UTC
+++ This bug was initially created as a clone of Bug #435398 +++
Fix went into 5.3, and customer is reporting Regression. 

[...]

--- Additional comment from s.hart.edu on 2009-04-09 21:42:53 EDT ---

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.

--- Additional comment from jbwells.uk on 2009-08-04 06:13:17 EDT ---

(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 2 Chris Ward 2009-08-05 11:53:47 UTC

*** This bug has been marked as a duplicate of bug 495642 ***


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