bug-bash
[Top][All Lists]
Advanced

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

Re: Documentation issue


From: Pierre Gaston
Subject: Re: Documentation issue
Date: Thu, 26 Oct 2017 10:58:08 +0300

On Thu, Oct 26, 2017 at 8:18 AM, Eli Barzilay <eli@barzilay.org> wrote:

> Bash surprised me with the behavior mentioned here:
>
>     https://stackoverflow.com/questions/15897473
>
> This can be pretty bad in that it's very unexpected (see the comments).
> Also, the surprise can be triggered without nullglob as well:
>
>     $ foo=(a b c)
>     $ touch foo0
>     $ unset foo[0]
>     $ echo ${foo[*]}
>     a b c
>
> The thing is that AFAICT, there is no mention of this pitfall in the man
> page...  It would be nice to mention using quotes in at least the
> `unset` description, and possibly also about `nullglob` too since it
> makes it easier to run into this problem.
>
> I grepped through the bash sources, and even there I found a few unsafe
> uses:
>
>     grep -r 'unset[^a-z"'\'']*\[' examples tests
>
> so this is clearly something that is not well-known enough.
>
> --
>                    ((x=>x(x))(x=>x(x)))                  Eli Barzilay:
>                    http://barzilay.org/                  Maze is Life!
>
>
I think it's even more likely to happen with eg: read array[i]

There is a large number of pitfalls in bash (
http://mywiki.wooledge.org/BashPitfalls) that most people ignore.
I'm not sure where to rank this one in the priorities of the ones that
would need to be mentioned in the manual.
Maybe one could create a separate man/info page that the manual could
reference?


reply via email to

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