BTS

Message1636

Author ft
Recipients mika
Date 2008-11-04.12:26:47
Content
Michael Prokop <bts@bts.grml.org>:
> Michael Prokop <mika@grml.org> added the comment:
> * Frank Terbeck <bts@bts.grml.org> [20081027 22:32]:
> 
> > I actually meant. How does command-not-found work? :-)
[...]

Back to this one...

[...]
> function preexec() {
>         command="${1%% *}"
> }
> 
> function precmd() {
>         (($?)) && [ -n "$command" ] && [ -x /usr/share/command-not-found/command-not-found ] && {
>                 whence -- "$command" >& /dev/null ||
>                         /usr/share/command-not-found/command-not-found -- "$command"
>                 unset command
>         }
> }

Okay, *if* we take a stab at this, I'm writing this from scratch.
<yoda>This I don't like.</yoda>

> So when sourcing this file and invoking a command which isn't
> present it displays which Debian package might provide the command.

Might? So it's basically just guessing? Or does it actually consult
the dpkg package database (which would be quite expensive, I think;
.o( apt-file nautilus | grep bin/ | awk { whatever } )).

> Demonstration (manually invoking
> /usr/share/command-not-found/command-not-found though here):
> 
> % /usr/share/command-not-found/command-not-found nautilus
> The program 'nautilus' is currently not installed.  To run 'nautilus' please ask your administrator to install the package 'nautilus'

Okay, I get the notion.
However:
    a) How does that thing get it's data?
    b) How accurate are its predictions?
    c) How well does it perform, if it's really accurate?

Regards, Frank
History
Date User Action Args
2008-11-04 12:26:49ftlinkissue564 messages
2008-11-04 12:26:47ftcreate