bug-bash
[Top][All Lists]
Advanced

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

Re: Substring Expansion does not work as intended


From: Davide Brini
Subject: Re: Substring Expansion does not work as intended
Date: Wed, 20 Aug 2014 15:53:41 +0200

On Wed, 20 Aug 2014 15:05:48 +0200, address@hidden wrote:

> Description:
>       Substring Expansion actually works different than manpage states,
> namely:
> 
>       "If offset evaluates to a number less than zero, the value is
> used as an offset from the end of the value of parameter."
> 
> Repeat-By:
>       x="abcdef"; echo "${x:-2}"
>       Expected: ef
>       Got:      abcdef
> 
>       or:
>       x="abcdef"; echo "${x:-2:1}"
>       Expected: e
>       Got:      abcdef

One line below it also says: "Note that a negative offset must be separated
from the colon by at least one space to avoid being confused  with  the  :-
expansion."

$ x="abcdef"; echo "${x: -2}"
ef
$ x="abcdef"; echo "${x: -2:1}"
e

-- 
D.



reply via email to

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