On Fri, Jan 26, 2018 at 09:41:45AM +0100, Klemens Nanni wrote:
> On Wed, Jan 24, 2018 at 04:15:24PM +0100, [email protected] wrote:
> > I found a bug in ksh's parameter expansion on an edge case:
> >
> > true $(true "${USER#'"'}")
> >
> > /home/sh[4]: no closing quote
> >
> > The problem seems to occurs when all of these conditions are present:
> >
> > 1. On ${var#pattern} or ${var%pattern} parameter expansion
> > 2. When the pattern contains a singly quoted double quote: '"'
> > 3. While expansion occurs withing $(...), (but not `...`)
> > 4. While the expansion is quoted: "${var#pattern}".
> As anton@ pointed out, this is known behaviour. The following will work:
>
> true $(true "${USER#\"}")
> true $(true "${USER#"\""}")
>
Forgot to mention: `` are not subject to this, the bug lives in $() alone.