|
From: | Chris F.A. Johnson |
Subject: | Re: Substring Expansion does not work as intended |
Date: | Wed, 20 Aug 2014 15:52:05 -0400 (EDT) |
User-agent: | Alpine 2.10 (DEB 1266 2009-07-14) |
On Wed, 20 Aug 2014, Eric Blake wrote:
On 08/20/2014 07:05 AM, eckard.brauer@gmx.de wrote: Not a bug.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."Read further. "Note that a negative offset must be separated from the colon by at least one space to avoid being confused with the :- expansion."Repeat-By: x="abcdef"; echo "${x:-2}" Expected: ef Got: abcdefecho "${x: -2}"
Or use a variable: o=-2 echo "${x:$o}" -- Chris F.A. Johnson, <http://cfajohnson.com>
[Prev in Thread] | Current Thread | [Next in Thread] |