bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Negative offset with variable expansion doesn't work


From: Chet Ramey
Subject: Re: Negative offset with variable expansion doesn't work
Date: Tue, 21 May 2002 10:43:46 -0400

> Reproduced with both 2.04 and 2.05:
> 
> var=12345
> echo ${var:-2:2}
> 
> results in
> 12345

Of course.  The `:-' doesn't specify a negative offset.  It has a
well-defined meaning: expand to `2:2' if `var' is unset or null.  If
you want to use a negative offset in this context, use

        echo ${var: -2:2}

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]