Control: reopen -1
Control: found -1 1.09
Control: retitle -1 dlocate: -lsbin doesn't work when awk is mawk, missing 
package relation with gawk
Control: tag -1 + patch

Dear Craig,

Debian Bug Tracking System wrote:
>    * Closes: #903773 Can not reproduce

A bug which you can't reproduce has no business to get closed in a
debian/changelog entry!

Please tag such bug reports as "unreproducible" and ask the bug report
for more details (and maybe tag it with "moreinfo" as well).

I still can reproduce this issue — at least on one machine. And I
can't reproduce it on another (and probably never could there). And I
now figured out what's the difference between those two machines:

As you might know, there are two awk implementations in Debian: mawk
and gawk. By default only mawk is installed (and is always there due
to "Priority: required") while gawk is optional (but IIRC default if
installed).

On the system where "dlocate -lsbin" works, the symlinks look like this:

  lrwxrwxrwx 1 root root 21 […] /usr/bin/awk -> /etc/alternatives/awk*
  lrwxrwxrwx 1 root root 13 […] /etc/alternatives/awk -> /usr/bin/gawk*

On the system where "dlocate -lsbin" gives no output, the symlinks
look like this:

  lrwxrwxrwx 1 root root 21 […] /usr/bin/awk -> /etc/alternatives/awk*
  lrwxrwxrwx 1 root root 13 […] /etc/alternatives/awk -> /usr/bin/mawk*

Culprit is this call:

  awk '!/^[^-]/ &&  /^-.{2,8}[xs]/ {print $2}'

mawk doesn't know about {x,y} quantifiers in regular expressions, and
since there is never a { at the second column in the output… Proof:

  $ dlocate -L zsh | xargs -d '\n' -r stat -c '%A %n' | gawk '!/^[^-]/ &&  
/^-.{2,8}[xs]/ {print $2}'
  /bin/zsh
  /bin/zsh5
  /usr/share/bug/zsh
  $ dlocate -L zsh | xargs -d '\n' -r stat -c '%A %n' | mawk '!/^[^-]/ &&  
/^-.{2,8}[xs]/ {print $2}'
  $

So "dlocate -lsbin" doesn't work with Debian's default awk
installation. (And btw. the "!/^[^-]/" is redundant as "/^-…/" is
equivalent.)

So I recommend to replace this gawk-ism with the following much
simpler and POSIX compatible pattern and match it only against the
first column so the quantifiers are no more needed:

  $1 ~ /^-.*[xs]/

Proof:

  $ dlocate -L zsh | xargs -d '\n' -r stat -c '%A %n' | gawk '$1 ~ /^-.*[xs]/ 
{print $2}'
  /bin/zsh
  /bin/zsh5
  /usr/share/bug/zsh
  $ dlocate -L zsh | xargs -d '\n' -r stat -c '%A %n' | mawk '$1 ~ /^-.*[xs]/ 
{print $2}'
  /bin/zsh
  /bin/zsh5
  /usr/share/bug/zsh

This is IMHO the better and cleaner alternative to adding a Depends or
at least Recommends on gawk which — with the current code base — is
clearly missing.

                Regards, Axel
-- 
 ,''`.  |  Axel Beckert <a...@debian.org>, https://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5
  `-    |  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE

Attachment: signature.asc
Description: PGP signature

Reply via email to