Bug 471784 - Problem with makewhatis dans command name with dash
Problem with makewhatis dans command name with dash
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: man (Show other bugs)
9
All Linux
medium Severity medium
: ---
: ---
Assigned To: Ivana Varekova
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-16 04:11 EST by pmarion
Modified: 2010-06-22 08:27 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-11-19 05:35:51 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description pmarion 2008-11-16 04:11:15 EST
Description of problem:

When makewhatis constructs its database, there is a problem if the command name contain a dash.
Exemple

with the command ssh-agent the result in /var/cache/man/whatis is 

ssh [] (1) - agent - xxxxxxxxxxxxxxxx
instead of
ssh-agent (1) - xxxxxxxxxxxxxxxx

And when we use a command like 'apropos agent' we get 
ssh [] (1) - agent - xxxxxxxxxxxxxxxx
Comment 1 pmarion 2008-11-16 04:29:34 EST
In the script makewhatis the problem seems to be located there
if ($0 ~ progname"-") {  # Fix old cat pages
  sub(progname"-", progname" - ");
}

I tried to replace 
sub(progname"-", progname"---");
I get
ssh---agent []       (1)  - authentication agent

It's not the real fix, but a way to locate where could be the solution.
Comment 2 Ivana Varekova 2008-11-19 05:35:51 EST
Thanks, fixed in man-1.6f-12.fc11.
Comment 3 Philip Spencer 2009-02-05 12:50:07 EST
This is actually the wrong fix. The problem is not in the lines of code

if ($0 ~ progname"-") {  # Fix old cat pages
  sub(progname"-", progname" - ");
}

-- those lines of code are fine and can be uncommented again.

The actual cause of the problem is that "progname" is set to be the EMPTY STRING.

If it were correctly set to the program name, the above code would be fine and would change things like "ssh-agent-description here" to
"ssh-agent - description here".

However, because it is empty, it causes the observed problem.

That is also why running "whatis man" (for example) gives

man []               (1)  - format and display the on-line manual pages

with the empty string in square brackets -- which should not be there!

The real cause of both these problems is earlier:

              use_zcat = match(filename,"\\.Z$") ||
               match(filename,"\\.z$") || match(filename,"\\.gz$");
              if (!use_zcat)
                use_bzcat = match(filename,"\\.bz2");
  ****===>    if(!use_bzcat)
                use_lzcat = match(filename,"\\.lzma");
              if (use_zcat || use_bzcat || use_lzcat ) {
                filename_no_gz = substr(filename, 0, RSTART - 1);
              } else {
                filename_no_gz = filename;
              }
              match(filename_no_gz, "/[^/]+$");
              progname = substr(filename, RSTART + 1, RLENGTH - 1);

The line marked ***====> is the problem. It should be replaced with

    if (!use_zcat && ! use_bzcat)

As it stands, with gzipped manpages, z_cat is set to true by the first line, which also sets RSTART to the beginning of the .gz suffix. Then the use_bzcat assignment is (correctly) skipped, leaving use_bzcat false. 

Then the problem line sees that use_bzcat is false and tries to assign use_lzcat. In so doing it runs another match command, which fails, and which overwrites RSTART and RLENGTH to zero. The final line then sets progname to the empty string.

In summary:

The fix is to put back in the lines that were commented out in the first fix attempt, and instead to alter the single line marked with ***====> above.

Can somebody with write-access to this bug please reopen it?

Thanks!
Comment 4 Tim Landscheidt 2010-06-22 08:27:06 EDT
For anyone who stumbles here like me: It wasn't fixed until Fedora 11's man-1.6f-21.fc11 (including) at least, Fedora 13's seems to incorporate Philip's patch.

Note You need to log in before you can comment on or make changes to this bug.