[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 18:54:20 -0300 |
Right, and they just have this in the distro's `/etc/bash.bashrc`:
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x
/usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -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" >&2
return 127
fi
}
fi
so if one forgets to `apt-get remove --purge python3-commandnotfound`,
their script kicks in.
On Tue, 9 Mar 2021 at 18:46, Eduardo Bustamante <dualbus@gmail.com> wrote:
> On Tue, Mar 9, 2021 at 1:40 PM Peng Yu <pengyu.ut@gmail.com> wrote:
> >
> > Hi,
> >
> > On ubuntu, if a command is not found, it will be prompt to get it
> > installed. Does anybody know this is achieved in bash? Thanks.
> >
> > $ shc
> > Command 'shc' not found, but can be installed with:
> > sudo apt install shc
> > Do you want to install it? (N/y)y
>
> Lookup `command_not_found_handle' in your Bash manual
>
>
- How to call something when a command is not found?, Peng Yu, 2021/03/09
- Re: How to call something when a command is not found?, Eduardo Bustamante, 2021/03/09
- Re: How to call something when a command is not found?,
Marco Ippolito <=
- Re: How to call something when a command is not found?, Peng Yu, 2021/03/09
- Re: How to call something when a command is not found?, Eli Schwartz, 2021/03/09
- Re: How to call something when a command is not found?, Peng Yu, 2021/03/09
- Re: How to call something when a command is not found?, Lawrence Velázquez, 2021/03/09
- Re: How to call something when a command is not found?, Eli Schwartz, 2021/03/09
- Re: How to call something when a command is not found?, Marco Ippolito, 2021/03/09
- Re: How to call something when a command is not found?, Lawrence Velázquez, 2021/03/09