help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to call something when a command is not found?


From: Marco Ippolito
Subject: Re: How to call something when a command is not found?
Date: Tue, 9 Mar 2021 20:10:55 -0300

Just:

set -x

and you'll trace the checks:

+ '[' -x /usr/lib/command-not-found ']'
+ '[' -x /usr/share/command-not-found/command-not-found ']'
...


On Tue, 9 Mar 2021 at 19:31, Peng Yu <pengyu.ut@gmail.com> wrote:

> My question was to Marco. You don't need to reply it.
>
> command_not_found_handle does call /usr/lib/command-not-found. I don't
> understand why there is a difference in the output when I directly
> call /usr/lib/command-not-found or let bash call
> command_not_found_handle.
>
> $ type command_not_found_handle
> command_not_found_handle is a function
> command_not_found_handle ()
> {
>     if [ -x /usr/lib/command-not-found ]; then
>         /usr/lib/command-not-found -- "$1";
>         return $?;
>     else
>         if [ -x /usr/share/command-not-found/command-not-found ]; then
>             /usr/share/command-not-found/command-not-found -- "$1";
>             return $?;
>         else
>             printf "%s: command not found\n" "$1" 1>&2;
>             return 127;
>         fi;
>     fi
> }
>
> On 3/9/21, Eli Schwartz <eschwartz@archlinux.org> wrote:
> > On 3/9/21 5:13 PM, Peng Yu wrote:
> >> Thanks. The output looks like the following,
> >>
> >> $ /usr/lib/command-not-found shc
> >> Command 'shc' is available in the following places
> >>  * /bin/shc
> >>  * /usr/bin/shc
> >> shc: command not found
> >
> > That is an external disk executable "command-not-found".
> >
> > It is NOT the bash manual command_not_found_handle.
> >
> > Please try your research again.
> >
> > --
> > Eli Schwartz
> > Arch LinuxBug Wrangler and Trusted User
> >
> >
>
>
> --
> Regards,
> Peng
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]