[pacman-dev] [PATCH] repo-remove: Fix infinite loop when given a pkgname ending in '*'

Eli Schwartz eschwartz at archlinux.org
Sun Apr 28 02:49:13 UTC 2019


On 4/27/19 4:38 AM, Ralph Corderoy wrote:
> Hi Jan,
> 
>>> This happens because find_pkgentry() fails to account the case where
>>> globbing fails and the expression is taken literally.
>>
>> Maybe we should use failglob instead to provoke an error?
> 
> Wouldn't nullglob be better to skip the loop's body?
> 
>     $ touch foo bar
>     $ ls
>     bar  foo
>     $
>     $ shopt -u nullglob failglob
>     $ for f in *; do echo = $f; done
>     = bar
>     = foo
>     $ rm foo
>     $ for f in *; do echo = $f; done
>     = bar
>     $ rm bar
>     $ for f in *; do echo = $f; done
>     = *
>     $
>     $ touch foo bar
>     $ shopt -s nullglob
>     $ for f in *; do echo = $f; done
>     = bar
>     = foo
>     $ rm foo
>     $ for f in *; do echo = $f; done
>     = bar
>     $ rm bar
>     $ for f in *; do echo = $f; done
>     $

All three of you are wrong, or at least missing the point. :)

[[ foo = f* ]] is defined to have pattern-matching context, and in this
case, [[ pkgname* = pkgname** ]] matches true. If we do not want this
behavior, we need to quote this -- and by properly quoting where we are
supposed to quote, we don't need to stat for file existence, we don't
need to change the way the whole script handles globs, and we still get
the failing action we want. To be more precise, we get the exact
behavior and method of acquiring that behavior, which was originally
intended.

There are also other cases where this could matter, some of which are
long shots.

-- 
Eli Schwartz
Bug Wrangler and Trusted User

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1601 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20190427/fac1d1a4/attachment.sig>


More information about the pacman-dev mailing list