[pacman-dev] brittle matching in lint_pkgbuild

Dave Reisner d at falconindy.com
Tue Feb 2 23:04:32 UTC 2016


Hi,

23f128ad5e2b causes problems when the environment isn't wholly
sanitized. Specifically, pattern matching such as:

  if [[ "$(declare -p $i)" != "declare -a "* ]]; then

Is too brittle. You can easily "break" makepkg by doing something like:

  export arch=; makepkg

And makepkg will error out with:

  ==> ERROR: arch should be an array

It *is* an array, but the decl looks like:

  declare -ax arch='([0]="i686" [1]="x86_64")'

And the originally stated pattern matching fails. If we want to continue
to match arrays based on this sort of introspection, we should make the
pattern a bit more robust -- something like:

  if [[ $(declare -p "$i") != declare\ -*([[:alnum:]])a*([[:alnum:]])\ * ]]; then

And this would be immune to other attributes which might show up in the
output of 'declare -p'.

Cheers,
dR


More information about the pacman-dev mailing list