bug-bash
[Top][All Lists]
Advanced

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

Re: Positional parameter & array slicing bug with empty arguments


From: Pierre Gaston
Subject: Re: Positional parameter & array slicing bug with empty arguments
Date: Sun, 12 Jan 2014 09:52:22 +0200

On Sun, Jan 12, 2014 at 3:11 AM, Theodoros V. Kalamatianos <address@hidden
> wrote:

> Hi,
>
> I have bumped into a rather strange issue:
>
> $ set -- ''; printf "=%s=\n" "$@" x
> ==
> =x=
> $ set -- ''; printf "=%s=\n" "${@:1}" x
> =x=
>
> Notice how in the second version the empty positional parameter is no
> longer displayed. Also compare with this version:
>
> $ set -- '' ''; printf "=%s=\n" "${@:1}" x
> =x=
> ==
> ==
>
> Now both empty arguments appear nornally. Also this check verifies that
> this is not a `printf' issue:
>
> $ set -- ''; set -- "${@:1}"; echo "$#"
> 0
>
> It seems that the issue has something to do with expanding a slice with a
> single empty element:
>
> $ set -- '' ''; printf "=%s=\n" "${@:1:1}" x
> =x=
>
> The same issue also happens with arrays:
>
> $ A=('' ''); printf "=%s=\n" "address@hidden:0}" x
> ==
> ==
> =x=
> $ A=('' ''); printf "=%s=\n" "address@hidden:0:1}" x
> =x=
> $ A=('' ''); printf "=%s=\n" "address@hidden:1}" x
> =x=
>
> I encountered this on bash-4.2.037, as provided by the Mageia 3 Linux
> distribution, but according to a contact on IRC, this issue also affects
> the latest patch (4.2.045).
>
> I would be happy to provide any information that you may need.
>
>
> Best regards,
>
> Theodoros V. Kalamatianos
>
> patch 32 seems to have caused this


reply via email to

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