[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Substring Expansion does not work as intended
From: |
Eckard Brauer |
Subject: |
Re: Substring Expansion does not work as intended |
Date: |
Wed, 20 Aug 2014 16:16:44 +0200 |
Hello,
I see.
My fault - thanks for the lesson... thought I had already used that at
a time, but can't remember for sure.
@Greg: The explanation does illustrate it very nice, as I regularly use
the ":-" - should have noticed that.
Thanks again, and kind regards
Eckard
Am Wed, 20 Aug 2014 07:50:09 -0600
schrieb Eric Blake <eblake@redhat.com>:
> 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: abcdef
>
> echo "${x: -2}"
>
> >
> > or:
> > x="abcdef"; echo "${x:-2:1}"
> > Expected: e
> > Got: abcdef
>
> echo "${x: -2:1}"
>
--
:)
signature.asc
Description: PGP signature