Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Backed up the system lately?


devel / comp.unix.shell / Non-installed programs and installation hints (from shell?)

SubjectAuthor
* Non-installed programs and installation hints (from shell?)Janis Papanagnou
+* Re: Non-installed programs and installation hints (from shell?)Anssi Saari
|`* Re: Non-installed programs and installation hints (from shell?)Janis Papanagnou
| +- Re: Non-installed programs and installation hints (from shell?)David W. Hodgins
| +- Re: Non-installed programs and installation hints (from shell?)Janis Papanagnou
| `* Re: Non-installed programs and installation hints (from shell?)Christian Weisgerber
|  `- Re: Non-installed programs and installation hints (from shell?)Janis Papanagnou
+* Re: Non-installed programs and installation hints (from shell?)Christian Weisgerber
|`- Re: Non-installed programs and installation hints (from shell?)Janis Papanagnou
`* Re: Non-installed programs and installation hints (from shell?)hongy...@gmail.com
 `* Re: Non-installed programs and installation hints (from shell?)Ottavio Caruso
  `* Re: Non-installed programs and installation hints (from shell?)hongy...@gmail.com
   `* Re: Non-installed programs and installation hints (from shell?)Ottavio Caruso
    +* Re: Non-installed programs and installation hints (from shell?)Keith Thompson
    |`- Re: Non-installed programs and installation hints (from shell?)hongy...@gmail.com
    `- Re: Non-installed programs and installation hints (from shell?)hongy...@gmail.com

1
Non-installed programs and installation hints (from shell?)

<s737e4$8hd$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3722&group=comp.unix.shell#3722

 copy link   Newsgroups: comp.unix.shell alt.os.linux.ubuntu
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell,alt.os.linux.ubuntu
Subject: Non-installed programs and installation hints (from shell?)
Date: Fri, 7 May 2021 13:14:12 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 21
Message-ID: <s737e4$8hd$1@news-1.m-online.net>
NNTP-Posting-Host: 2001:a61:252a:da01:e121:b835:c296:5c24
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1620386052 8749 2001:a61:252a:da01:e121:b835:c296:5c24 (7 May 2021 11:14:12 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Fri, 7 May 2021 11:14:12 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
X-Mozilla-News-Host: news://news.m-online.net:119
Content-Language: en-US
 by: Janis Papanagnou - Fri, 7 May 2021 11:14 UTC

If on Ubuntu I issue a command name of a program that is not installed
I get an installation hint from a *bash* command shell like

$ stellarium

Command 'stellarium' not found, but can be installed with:

sudo apt install stellarium

In a *ksh93* context I don't get that hint

$ stellarium
ksh93: stellarium: not found [No such file or directory]

Does anyone know the underlying mechanism (in bash or generally Ubuntu)
how that is achieved. (In the bash dotfiles I didn't see anything but
may also just have missed it.)

Janis

Re: Non-installed programs and installation hints (from shell?)

<sm0fsyy93yc.fsf@lakka.kapsi.fi>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3723&group=comp.unix.shell#3723

 copy link   Newsgroups: comp.unix.shell alt.os.linux.ubuntu
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: as...@sci.fi (Anssi Saari)
Newsgroups: comp.unix.shell,alt.os.linux.ubuntu
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 07 May 2021 14:30:03 +0300
Organization: An impatient and LOUD arachnid
Lines: 11
Message-ID: <sm0fsyy93yc.fsf@lakka.kapsi.fi>
References: <s737e4$8hd$1@news-1.m-online.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="c5bfe7f5bdc4f304cf5de3e32c41522d";
logging-data="22090"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OFPEhx+uv+nMGq9/QJ1R8"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:PgmmXRVWyjvXj7binvzfv/lIrB8=
sha1:OuhATfd56tJHKJUNguSpQEN14O4=
 by: Anssi Saari - Fri, 7 May 2021 11:30 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> Does anyone know the underlying mechanism (in bash or generally Ubuntu)
> how that is achieved. (In the bash dotfiles I didn't see anything but
> may also just have missed it.)

The command-not-found command from the package with the same name
provides the information and the default /etc/bash.bashrc uses that
package if it's installed. The way it works in bash and zsh is that the
shell executes a specific function if a command is not found, if that
functions is defined. Presumably ksh93 doesn't have that feature.

Re: Non-installed programs and installation hints (from shell?)

<s73cn2$a65$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3724&group=comp.unix.shell#3724

 copy link   Newsgroups: comp.unix.shell alt.os.linux.ubuntu
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell,alt.os.linux.ubuntu
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 7 May 2021 14:44:18 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 24
Message-ID: <s73cn2$a65$1@news-1.m-online.net>
References: <s737e4$8hd$1@news-1.m-online.net>
<sm0fsyy93yc.fsf@lakka.kapsi.fi>
NNTP-Posting-Host: 2001:a61:252a:da01:e121:b835:c296:5c24
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1620391458 10437 2001:a61:252a:da01:e121:b835:c296:5c24 (7 May 2021 12:44:18 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Fri, 7 May 2021 12:44:18 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
In-Reply-To: <sm0fsyy93yc.fsf@lakka.kapsi.fi>
Content-Language: en-US
 by: Janis Papanagnou - Fri, 7 May 2021 12:44 UTC

On 07.05.21 13:30, Anssi Saari wrote:
> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>
>> Does anyone know the underlying mechanism (in bash or generally Ubuntu)
>> how that is achieved. (In the bash dotfiles I didn't see anything but
>> may also just have missed it.)
>
> The command-not-found command from the package with the same name
> provides the information and the default /etc/bash.bashrc uses that
> package if it's installed. The way it works in bash and zsh is that the
> shell executes a specific function if a command is not found, if that
> functions is defined. Presumably ksh93 doesn't have that feature.

Thanks. So file '/etc/bash.bashrc' is the key to find the code.

And in ksh it would in principle be possible to also capture the
error, e.g. by

trap '[ $? -eq 127 ] && command_not_found_handle "${...}"' ERR

if only we had (where I wrote "${...}") the name of the command
available that produced the error.

Janis

Re: Non-installed programs and installation hints (from shell?)

<op.020zfaqva3w0dxdave@hodgins.homeip.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3725&group=comp.unix.shell#3725

 copy link   Newsgroups: comp.unix.shell alt.os.linux.ubuntu
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell,alt.os.linux.ubuntu
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 07 May 2021 09:51:00 -0400
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <op.020zfaqva3w0dxdave@hodgins.homeip.net>
References: <s737e4$8hd$1@news-1.m-online.net>
<sm0fsyy93yc.fsf@lakka.kapsi.fi> <s73cn2$a65$1@news-1.m-online.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="1f50cf5e6fe9cb5b4ca1a2d8e738e816";
logging-data="13002"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18t3+u91U5DYbbXxtov9wStImJ0Z0uW9OM="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:xZUqSK6S9dUrapYgbABrlz/JB/U=
 by: David W. Hodgins - Fri, 7 May 2021 13:51 UTC

On Fri, 07 May 2021 08:44:18 -0400, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> if only we had (where I wrote "${...}") the name of the command
> available that produced the error.

In Mageia it's the package packagekit-command-not-found
which contains /etc/profile.d/PackageKit.sh and /usr/libexec/pk-command-not-found

Regards, Dave Hodgins

--
Change dwhodgins@nomail.afraid.org to davidwhodgins@teksavvy.com for
email replies.

Re: Non-installed programs and installation hints (from shell?)

<s73iis$vgh$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3726&group=comp.unix.shell#3726

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!SzquvauBMar4q7xfFGKjCA.user.gioia.aioe.org.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 7 May 2021 16:24:29 +0200
Organization: Aioe.org NNTP Server
Lines: 23
Message-ID: <s73iis$vgh$1@gioia.aioe.org>
References: <s737e4$8hd$1@news-1.m-online.net>
<sm0fsyy93yc.fsf@lakka.kapsi.fi> <s73cn2$a65$1@news-1.m-online.net>
NNTP-Posting-Host: SzquvauBMar4q7xfFGKjCA.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Notice: Filtered by postfilter v. 0.9.2
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 7 May 2021 14:24 UTC

On 07.05.2021 14:44, Janis Papanagnou wrote:
>
> And in ksh it would in principle be possible to also capture the
> error, e.g. by
>
> trap '[ $? -eq 127 ] && command_not_found_handle "${...}"' ERR
>
> if only we had (where I wrote "${...}") the name of the command
> available that produced the error.

It's a pity that (in Kornshell) in context of the DEBUG trap such a
variable is set

trap 'echo ${.sh.command}' DEBUG

but that for the ERR trap the value of that variable is not defined,

trap 'echo ${.sh.command}' ERR

produces no output. Would have been useful.

Janis

Re: Non-installed programs and installation hints (from shell?)

<slrns9ai3m.174r.naddy@lorvorc.mips.inka.de>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3727&group=comp.unix.shell#3727

 copy link   Newsgroups: comp.unix.shell alt.os.linux.ubuntu
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: nad...@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell,alt.os.linux.ubuntu
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 7 May 2021 14:02:30 -0000 (UTC)
Message-ID: <slrns9ai3m.174r.naddy@lorvorc.mips.inka.de>
References: <s737e4$8hd$1@news-1.m-online.net>
Injection-Date: Fri, 7 May 2021 14:02:30 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="40875"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Fri, 7 May 2021 14:02 UTC

On 2021-05-07, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:

> $ stellarium
>
> Command 'stellarium' not found, but can be installed with:
>
> sudo apt install stellarium
>
> Does anyone know the underlying mechanism (in bash or generally Ubuntu)
> how that is achieved.

Bash has a hook that allows you to intercept "command not found"
errors. I once played around with this to catch all commands of
the form <number>x<number>, e.g. 100x40, and resize xterm accordingly.

From the man page, section "Command Execution":
If the search is unsuccessful, the shell searches for a defined
shell function named command_not_found_handle. If that function
exists, it is invoked in a separate execution environment with the
original command and the original command's arguments as its
arguments, and the function's exit status becomes the exit status
of that subshell.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: Non-installed programs and installation hints (from shell?)

<slrns9akvh.18md.naddy@lorvorc.mips.inka.de>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3728&group=comp.unix.shell#3728

 copy link   Newsgroups: comp.unix.shell alt.os.linux.ubuntu
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: nad...@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell,alt.os.linux.ubuntu
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 7 May 2021 14:51:29 -0000 (UTC)
Message-ID: <slrns9akvh.18md.naddy@lorvorc.mips.inka.de>
References: <s737e4$8hd$1@news-1.m-online.net>
<sm0fsyy93yc.fsf@lakka.kapsi.fi> <s73cn2$a65$1@news-1.m-online.net>
Injection-Date: Fri, 7 May 2021 14:51:29 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="41678"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Fri, 7 May 2021 14:51 UTC

On 2021-05-07, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:

> And in ksh it would in principle be possible to also capture the
> error, e.g. by
>
> trap '[ $? -eq 127 ] && command_not_found_handle "${...}"' ERR
>
> if only we had (where I wrote "${...}") the name of the command
> available that produced the error.

I guess you could extract it by way of hist -l $((HISTCMD - 1)).

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: Non-installed programs and installation hints (from shell?)

<s73oj3$dkr$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3729&group=comp.unix.shell#3729

 copy link   Newsgroups: comp.unix.shell alt.os.linux.ubuntu
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell,alt.os.linux.ubuntu
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 7 May 2021 18:06:59 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 23
Message-ID: <s73oj3$dkr$1@news-1.m-online.net>
References: <s737e4$8hd$1@news-1.m-online.net>
<sm0fsyy93yc.fsf@lakka.kapsi.fi> <s73cn2$a65$1@news-1.m-online.net>
<slrns9akvh.18md.naddy@lorvorc.mips.inka.de>
NNTP-Posting-Host: 2001:a61:252a:da01:e121:b835:c296:5c24
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1620403620 13979 2001:a61:252a:da01:e121:b835:c296:5c24 (7 May 2021 16:07:00 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Fri, 7 May 2021 16:07:00 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
In-Reply-To: <slrns9akvh.18md.naddy@lorvorc.mips.inka.de>
Content-Language: en-US
 by: Janis Papanagnou - Fri, 7 May 2021 16:06 UTC

On 07.05.21 16:51, Christian Weisgerber wrote:
> On 2021-05-07, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>
>> And in ksh it would in principle be possible to also capture the
>> error, e.g. by
>>
>> trap '[ $? -eq 127 ] && command_not_found_handle "${...}"' ERR
>>
>> if only we had (where I wrote "${...}") the name of the command
>> available that produced the error.
>
> I guess you could extract it by way of hist -l $((HISTCMD - 1)).

Ah, yes, of course. (Need some more coffee, I guess.) - Thanks!

With your suggestion I tested this variant in my ksh environment

trap '[ $? -eq 127 ] && command_not_found_handle $(fc -ln -0)' ERR

and (with the respective function definition) it basically works.
(Need only to get rid of the duplicate "not found" information.)

Janis

Re: Non-installed programs and installation hints (from shell?)

<s73orf$dle$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3730&group=comp.unix.shell#3730

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Fri, 7 May 2021 18:11:27 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 10
Message-ID: <s73orf$dle$1@news-1.m-online.net>
References: <s737e4$8hd$1@news-1.m-online.net>
<slrns9ai3m.174r.naddy@lorvorc.mips.inka.de>
NNTP-Posting-Host: 2001:a61:252a:da01:e121:b835:c296:5c24
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1620403887 13998 2001:a61:252a:da01:e121:b835:c296:5c24 (7 May 2021 16:11:27 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Fri, 7 May 2021 16:11:27 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
In-Reply-To: <slrns9ai3m.174r.naddy@lorvorc.mips.inka.de>
Content-Language: en-US
 by: Janis Papanagnou - Fri, 7 May 2021 16:11 UTC

On 07.05.21 16:02, Christian Weisgerber wrote:
>
> Bash has a hook that allows you to intercept "command not found"
> errors. I once played around with this to catch all commands of
> the form <number>x<number>, e.g. 100x40, and resize xterm accordingly.

A useful code pattern. (Another application is for arbitrary dice, like
3d20 command.)

Janis

Re: Non-installed programs and installation hints (from shell?)

<c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3731&group=comp.unix.shell#3731

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:6c1:: with SMTP id j1mr1062195qth.350.1620439405442; Fri, 07 May 2021 19:03:25 -0700 (PDT)
X-Received: by 2002:a05:622a:650:: with SMTP id a16mr12220218qtb.316.1620439405188; Fri, 07 May 2021 19:03:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder5.feed.usenet.farm!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 7 May 2021 19:03:24 -0700 (PDT)
In-Reply-To: <s737e4$8hd$1@news-1.m-online.net>
Injection-Info: google-groups.googlegroups.com; posting-host=158.101.136.126; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 158.101.136.126
References: <s737e4$8hd$1@news-1.m-online.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
Subject: Re: Non-installed programs and installation hints (from shell?)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sat, 08 May 2021 02:03:25 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 110
 by: hongy...@gmail.com - Sat, 8 May 2021 02:03 UTC

On Friday, May 7, 2021 at 7:14:16 PM UTC+8, Janis Papanagnou wrote:
> If on Ubuntu I issue a command name of a program that is not installed
> I get an installation hint from a *bash* command shell like
>
> $ stellarium
>
> Command 'stellarium' not found, but can be installed with:
>
> sudo apt install stellarium
>
>
> In a *ksh93* context I don't get that hint
>
> $ stellarium
> ksh93: stellarium: not found [No such file or directory]
>
>
> Does anyone know the underlying mechanism (in bash or generally Ubuntu)
> how that is achieved. (In the bash dotfiles I didn't see anything but
> may also just have missed it.)

It seems that this function is implemented through a library on Ubuntu as indicated by the following files:

$ apt-file search command-not-found
command-not-found: /etc/apt/apt.conf.d/50command-not-found
command-not-found: /usr/lib/command-not-found
command-not-found: /usr/share/doc/command-not-found/README.md
command-not-found: /usr/share/doc/command-not-found/changelog.gz
command-not-found: /usr/share/doc/command-not-found/copyright
language-pack-af-base: /usr/share/locale-langpack/af/LC_MESSAGES/command-not-found.mo
language-pack-am-base: /usr/share/locale-langpack/am/LC_MESSAGES/command-not-found.mo
language-pack-an-base: /usr/share/locale-langpack/an/LC_MESSAGES/command-not-found.mo
language-pack-ar-base: /usr/share/locale-langpack/ar/LC_MESSAGES/command-not-found.mo
language-pack-ast-base: /usr/share/locale-langpack/ast/LC_MESSAGES/command-not-found.mo
language-pack-az-base: /usr/share/locale-langpack/az/LC_MESSAGES/command-not-found.mo
language-pack-be-base: /usr/share/locale-langpack/be/LC_MESSAGES/command-not-found.mo
language-pack-bg-base: /usr/share/locale-langpack/bg/LC_MESSAGES/command-not-found.mo
language-pack-br-base: /usr/share/locale-langpack/br/LC_MESSAGES/command-not-found.mo
language-pack-bs-base: /usr/share/locale-langpack/bs/LC_MESSAGES/command-not-found.mo
language-pack-ca-base: /usr/share/locale-langpack/ca/LC_MESSAGES/command-not-found.mo
language-pack-ca-base: /usr/share/locale-langpack/ca@valencia/LC_MESSAGES/command-not-found.mo
language-pack-cs-base: /usr/share/locale-langpack/cs/LC_MESSAGES/command-not-found.mo
language-pack-cy-base: /usr/share/locale-langpack/cy/LC_MESSAGES/command-not-found.mo
language-pack-da-base: /usr/share/locale-langpack/da/LC_MESSAGES/command-not-found.mo
language-pack-de-base: /usr/share/locale-langpack/de/LC_MESSAGES/command-not-found.mo
language-pack-el-base: /usr/share/locale-langpack/el/LC_MESSAGES/command-not-found.mo
language-pack-en-base: /usr/share/locale-langpack/en_AU/LC_MESSAGES/command-not-found.mo
language-pack-en-base: /usr/share/locale-langpack/en_CA/LC_MESSAGES/command-not-found.mo
language-pack-en-base: /usr/share/locale-langpack/en_GB/LC_MESSAGES/command-not-found.mo
language-pack-eo-base: /usr/share/locale-langpack/eo/LC_MESSAGES/command-not-found.mo
language-pack-es-base: /usr/share/locale-langpack/es/LC_MESSAGES/command-not-found.mo
language-pack-et-base: /usr/share/locale-langpack/et/LC_MESSAGES/command-not-found.mo
language-pack-eu-base: /usr/share/locale-langpack/eu/LC_MESSAGES/command-not-found.mo
language-pack-fa-base: /usr/share/locale-langpack/fa/LC_MESSAGES/command-not-found.mo
language-pack-fi-base: /usr/share/locale-langpack/fi/LC_MESSAGES/command-not-found.mo
language-pack-fr-base: /usr/share/locale-langpack/fr/LC_MESSAGES/command-not-found.mo
language-pack-gl-base: /usr/share/locale-langpack/gl/LC_MESSAGES/command-not-found.mo
language-pack-gu-base: /usr/share/locale-langpack/gu/LC_MESSAGES/command-not-found.mo
language-pack-he-base: /usr/share/locale-langpack/he/LC_MESSAGES/command-not-found.mo
language-pack-hi-base: /usr/share/locale-langpack/hi/LC_MESSAGES/command-not-found.mo
language-pack-hr-base: /usr/share/locale-langpack/hr/LC_MESSAGES/command-not-found.mo
language-pack-hu-base: /usr/share/locale-langpack/hu/LC_MESSAGES/command-not-found.mo
language-pack-id-base: /usr/share/locale-langpack/id/LC_MESSAGES/command-not-found.mo
language-pack-is-base: /usr/share/locale-langpack/is/LC_MESSAGES/command-not-found.mo
language-pack-it-base: /usr/share/locale-langpack/it/LC_MESSAGES/command-not-found.mo
language-pack-ja-base: /usr/share/locale-langpack/ja/LC_MESSAGES/command-not-found.mo
language-pack-kk-base: /usr/share/locale-langpack/kk/LC_MESSAGES/command-not-found.mo
language-pack-km-base: /usr/share/locale-langpack/km/LC_MESSAGES/command-not-found.mo
language-pack-kn-base: /usr/share/locale-langpack/kn/LC_MESSAGES/command-not-found.mo
language-pack-ko-base: /usr/share/locale-langpack/ko/LC_MESSAGES/command-not-found.mo
language-pack-ku-base: /usr/share/locale-langpack/ku/LC_MESSAGES/command-not-found.mo
language-pack-lt-base: /usr/share/locale-langpack/lt/LC_MESSAGES/command-not-found.mo
language-pack-lv-base: /usr/share/locale-langpack/lv/LC_MESSAGES/command-not-found.mo
language-pack-mk-base: /usr/share/locale-langpack/mk/LC_MESSAGES/command-not-found.mo
language-pack-ml-base: /usr/share/locale-langpack/ml/LC_MESSAGES/command-not-found.mo
language-pack-ms-base: /usr/share/locale-langpack/ms/LC_MESSAGES/command-not-found.mo
language-pack-my-base: /usr/share/locale-langpack/my/LC_MESSAGES/command-not-found.mo
language-pack-nb-base: /usr/share/locale-langpack/nb/LC_MESSAGES/command-not-found.mo
language-pack-nds-base: /usr/share/locale-langpack/nds/LC_MESSAGES/command-not-found.mo
language-pack-nl-base: /usr/share/locale-langpack/nl/LC_MESSAGES/command-not-found.mo
language-pack-nn-base: /usr/share/locale-langpack/nn/LC_MESSAGES/command-not-found.mo
language-pack-oc-base: /usr/share/locale-langpack/oc/LC_MESSAGES/command-not-found.mo
language-pack-pa-base: /usr/share/locale-langpack/pa/LC_MESSAGES/command-not-found.mo
language-pack-pl-base: /usr/share/locale-langpack/pl/LC_MESSAGES/command-not-found.mo
language-pack-pt-base: /usr/share/locale-langpack/pt/LC_MESSAGES/command-not-found.mo
language-pack-pt-base: /usr/share/locale-langpack/pt_BR/LC_MESSAGES/command-not-found.mo
language-pack-ro-base: /usr/share/locale-langpack/ro/LC_MESSAGES/command-not-found.mo
language-pack-ru-base: /usr/share/locale-langpack/ru/LC_MESSAGES/command-not-found.mo
language-pack-sk-base: /usr/share/locale-langpack/sk/LC_MESSAGES/command-not-found.mo
language-pack-sl-base: /usr/share/locale-langpack/sl/LC_MESSAGES/command-not-found.mo
language-pack-sq-base: /usr/share/locale-langpack/sq/LC_MESSAGES/command-not-found.mo
language-pack-sr-base: /usr/share/locale-langpack/sr/LC_MESSAGES/command-not-found.mo
language-pack-sv-base: /usr/share/locale-langpack/sv/LC_MESSAGES/command-not-found.mo
language-pack-th-base: /usr/share/locale-langpack/th/LC_MESSAGES/command-not-found.mo
language-pack-tr-base: /usr/share/locale-langpack/tr/LC_MESSAGES/command-not-found.mo
language-pack-ug-base: /usr/share/locale-langpack/ug/LC_MESSAGES/command-not-found.mo
language-pack-uk-base: /usr/share/locale-langpack/uk/LC_MESSAGES/command-not-found.mo
language-pack-vi-base: /usr/share/locale-langpack/vi/LC_MESSAGES/command-not-found.mo
language-pack-zh-hans-base: /usr/share/locale-langpack/zh_CN/LC_MESSAGES/command-not-found.mo
language-pack-zh-hant-base: /usr/share/locale-langpack/zh_HK/LC_MESSAGES/command-not-found.mo
language-pack-zh-hant-base: /usr/share/locale-langpack/zh_TW/LC_MESSAGES/command-not-found.mo
packagekit-command-not-found: /usr/lib/packagekit/pk-command-not-found
packagekit-command-not-found: /usr/share/doc/packagekit-command-not-found/changelog.Debian.gz
packagekit-command-not-found: /usr/share/doc/packagekit-command-not-found/copyright

Especially, this file, /usr/share/doc/command-not-found/README.md, gives some hints on the mechanism relevant to its implementations, say, described at <https://wiki.ubuntu.com/CommandNotFoundMagic>.

HY
>
> Janis

Re: Non-installed programs and installation hints (from shell?)

<s75j00$6d5$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3732&group=comp.unix.shell#3732

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ottavio2...@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Sat, 8 May 2021 09:43:43 +0100
Organization: A noiseless patient Spider
Lines: 116
Message-ID: <s75j00$6d5$1@dont-email.me>
References: <s737e4$8hd$1@news-1.m-online.net>
<c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 8 May 2021 08:43:44 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="01215d44afa79e6a88127424b64f5f1f";
logging-data="6565"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185pzWGs+MlrHBvS3nL4/RRkqYbXm1yWi4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.3.1
Cancel-Lock: sha1:9elzgEMu9Gru3zPmFsT6xkTIwFU=
In-Reply-To: <c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
Content-Language: en-GB
 by: Ottavio Caruso - Sat, 8 May 2021 08:43 UTC

On my Debian Buster:

$ ll `which command-not-found`
lrwxrwxrwx 1 root root 44 Nov 21 2018 /usr/bin/command-not-found ->
.../share/command-not-found/command-not-found*

$ cat /usr/share/command-not-found/command-not-found
#!/usr/bin/python3
# (c) Zygmunt Krynicki 2005, 2006, 2007, 2008
# Licensed under GPL, see COPYING for the whole text

from __future__ import absolute_import, print_function

__version__ = "0.3"
BUG_REPORT_URL = "http://www.debian.org/Bugs/Reporting"

try:
import sys
if sys.path and sys.path[0] == '/usr/lib':
# Avoid ImportError noise due to odd installation location.
sys.path.pop(0)
if sys.version < '3':
# We might end up being executed with Python 2 due to an old
# /etc/bash.bashrc.
import os
if "COMMAND_NOT_FOUND_FORCE_PYTHON2" not in os.environ:
os.execvp("/usr/bin/python3", [sys.argv[0]] + sys.argv)

import gettext
import locale
from optparse import OptionParser

from CommandNotFound.util import crash_guard
from CommandNotFound import CommandNotFound
except KeyboardInterrupt:
import sys
sys.exit(127)

def enable_i18n():
cnf = gettext.translation("command-not-found", fallback=True)
kwargs = {}
if sys.version < '3':
kwargs["unicode"] = True
cnf.install(**kwargs)
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
locale.setlocale(locale.LC_ALL, 'C')

def fix_sys_argv(encoding=None):
"""
Fix sys.argv to have only unicode strings, not binary strings.
This is required by various places where such argument might be
automatically coerced to unicode string for formatting
"""
if encoding is None:
encoding = locale.getpreferredencoding()
sys.argv = [arg.decode(encoding) for arg in sys.argv]

class LocaleOptionParser(OptionParser):
"""
OptionParser is broken as its implementation of _get_encoding() uses
sys.getdefaultencoding() which is ascii, what it should be using is
locale.getpreferredencoding() which returns value based on LC_CTYPE
(most
likely) and allows for UTF-8 encoding to be used.
"""
def _get_encoding(self, file):
encoding = getattr(file, "encoding", None)
if not encoding:
encoding = locale.getpreferredencoding()
return encoding

def main():
enable_i18n()
if sys.version < '3':
fix_sys_argv()
parser = LocaleOptionParser(
version=__version__,
usage=_("%prog [options] <command-name>"))
parser.add_option('-d', '--data-dir', action='store',
default="/usr/share/command-not-found",
help=_("use this path to locate data fields"))
parser.add_option('--ignore-installed', '--ignore-installed',
action='store_true', default=False,
help=_("ignore local binaries and display the
available packages"))
parser.add_option('--no-failure-msg',
action='store_true', default=False,
help=_("don't print '<command-name>: command not
found'"))
(options, args) = parser.parse_args()
if len(args) == 1:
try:
cnf = CommandNotFound.CommandNotFound(options.data_dir,
do_raise=True)
except CommandNotFound.NoDatabaseError as e:
print(e)
if not cnf.advise(args[0], options.ignore_installed) and not
options.no_failure_msg:
print(_("%s: command not found") % args[0], file=sys.stderr)

if __name__ == "__main__":
crash_guard(main, BUG_REPORT_URL, __version__)

--
Ottavio Caruso

Re: Non-installed programs and installation hints (from shell?)

<e7d7e32d-69f7-42c8-8b40-7803f0c833c4n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3734&group=comp.unix.shell#3734

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:108b:: with SMTP id a11mr13877069qtj.16.1620478436928;
Sat, 08 May 2021 05:53:56 -0700 (PDT)
X-Received: by 2002:a37:45c7:: with SMTP id s190mr14233765qka.111.1620478436680;
Sat, 08 May 2021 05:53:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 8 May 2021 05:53:56 -0700 (PDT)
In-Reply-To: <s75j00$6d5$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=103.142.140.222; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 103.142.140.222
References: <s737e4$8hd$1@news-1.m-online.net> <c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
<s75j00$6d5$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e7d7e32d-69f7-42c8-8b40-7803f0c833c4n@googlegroups.com>
Subject: Re: Non-installed programs and installation hints (from shell?)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sat, 08 May 2021 12:53:56 +0000
Content-Type: text/plain; charset="UTF-8"
 by: hongy...@gmail.com - Sat, 8 May 2021 12:53 UTC

On Saturday, May 8, 2021 at 4:43:49 PM UTC+8, Ottavio Caruso wrote:
> On my Debian Buster:
>
> $ ll `which command-not-found`

Gives nothing for my case on Ubuntu 20.04:

werner@X10DAi:~$ which command-not-found
werner@X10DAi:~$

> lrwxrwxrwx 1 root root 44 Nov 21 2018 /usr/bin/command-not-found ->
> ../share/command-not-found/command-not-found*
>
>
> $ cat /usr/share/command-not-found/command-not-found
> #!/usr/bin/python3
> # (c) Zygmunt Krynicki 2005, 2006, 2007, 2008
> # Licensed under GPL, see COPYING for the whole text
>
> from __future__ import absolute_import, print_function
>
>
> __version__ = "0.3"
> BUG_REPORT_URL = "http://www.debian.org/Bugs/Reporting"
>
> try:
> import sys
> if sys.path and sys.path[0] == '/usr/lib':
> # Avoid ImportError noise due to odd installation location.
> sys.path.pop(0)
> if sys.version < '3':
> # We might end up being executed with Python 2 due to an old
> # /etc/bash.bashrc.
> import os
> if "COMMAND_NOT_FOUND_FORCE_PYTHON2" not in os.environ:
> os.execvp("/usr/bin/python3", [sys.argv[0]] + sys.argv)
>
> import gettext
> import locale
> from optparse import OptionParser
>
> from CommandNotFound.util import crash_guard
> from CommandNotFound import CommandNotFound
> except KeyboardInterrupt:
> import sys
> sys.exit(127)
>
>
> def enable_i18n():
> cnf = gettext.translation("command-not-found", fallback=True)
> kwargs = {}
> if sys.version < '3':
> kwargs["unicode"] = True
> cnf.install(**kwargs)
> try:
> locale.setlocale(locale.LC_ALL, '')
> except locale.Error:
> locale.setlocale(locale.LC_ALL, 'C')
>
>
> def fix_sys_argv(encoding=None):
> """
> Fix sys.argv to have only unicode strings, not binary strings.
> This is required by various places where such argument might be
> automatically coerced to unicode string for formatting
> """
> if encoding is None:
> encoding = locale.getpreferredencoding()
> sys.argv = [arg.decode(encoding) for arg in sys.argv]
>
>
> class LocaleOptionParser(OptionParser):
> """
> OptionParser is broken as its implementation of _get_encoding() uses
> sys.getdefaultencoding() which is ascii, what it should be using is
> locale.getpreferredencoding() which returns value based on LC_CTYPE
> (most
> likely) and allows for UTF-8 encoding to be used.
> """
> def _get_encoding(self, file):
> encoding = getattr(file, "encoding", None)
> if not encoding:
> encoding = locale.getpreferredencoding()
> return encoding
>
>
> def main():
> enable_i18n()
> if sys.version < '3':
> fix_sys_argv()
> parser = LocaleOptionParser(
> version=__version__,
> usage=_("%prog [options] <command-name>"))
> parser.add_option('-d', '--data-dir', action='store',
> default="/usr/share/command-not-found",
> help=_("use this path to locate data fields"))
> parser.add_option('--ignore-installed', '--ignore-installed',
> action='store_true', default=False,
> help=_("ignore local binaries and display the
> available packages"))
> parser.add_option('--no-failure-msg',
> action='store_true', default=False,
> help=_("don't print '<command-name>: command not
> found'"))
> (options, args) = parser.parse_args()
> if len(args) == 1:
> try:
> cnf = CommandNotFound.CommandNotFound(options.data_dir,
> do_raise=True)
> except CommandNotFound.NoDatabaseError as e:
> print(e)
> if not cnf.advise(args[0], options.ignore_installed) and not
> options.no_failure_msg:
> print(_("%s: command not found") % args[0], file=sys.stderr)
>
>
> if __name__ == "__main__":
> crash_guard(main, BUG_REPORT_URL, __version__)
>
>
>
> --
> Ottavio Caruso

Re: Non-installed programs and installation hints (from shell?)

<s766m2$aor$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3735&group=comp.unix.shell#3735

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ottavio2...@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Sat, 8 May 2021 15:19:45 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <s766m2$aor$1@dont-email.me>
References: <s737e4$8hd$1@news-1.m-online.net>
<c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
<s75j00$6d5$1@dont-email.me>
<e7d7e32d-69f7-42c8-8b40-7803f0c833c4n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 8 May 2021 14:19:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="01215d44afa79e6a88127424b64f5f1f";
logging-data="11035"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1CrT2Pt2/oN6ZBAuBpEuE0EwE+/uxiJQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.3.1
Cancel-Lock: sha1:pSckTLyA/rfaYt+6hgrVqZuL4I8=
In-Reply-To: <e7d7e32d-69f7-42c8-8b40-7803f0c833c4n@googlegroups.com>
Content-Language: en-GB
 by: Ottavio Caruso - Sat, 8 May 2021 14:19 UTC

On 08/05/2021 13:53, hongy...@gmail.com wrote:
> Gives nothing for my case on Ubuntu 20.04:
>
> werner@X10DAi:~$ which command-not-found
> werner@X10DAi:~$

What about:

type command-not-found

or

type command_not_found_handle

Is it a programs in Debian, but it could be a simple Bash function on
Ubuntu.

--
Ottavio Caruso

Re: Non-installed programs and installation hints (from shell?)

<87r1ig996l.fsf@nosuchdomain.example.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3736&group=comp.unix.shell#3736

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Non-installed programs and installation hints (from shell?)
Date: Sat, 08 May 2021 15:01:38 -0700
Organization: None to speak of
Lines: 49
Message-ID: <87r1ig996l.fsf@nosuchdomain.example.com>
References: <s737e4$8hd$1@news-1.m-online.net>
<c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
<s75j00$6d5$1@dont-email.me>
<e7d7e32d-69f7-42c8-8b40-7803f0c833c4n@googlegroups.com>
<s766m2$aor$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="55d05a18d8393d03b7168990b2fee17e";
logging-data="20099"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/P8UG4zb/ly1Yf006EnKRE"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Cancel-Lock: sha1:v2JhlONGsJkfzaXmGt+y2IkD86U=
sha1:a5W88oX5rrl4NLZ/2LpBk2//ONw=
 by: Keith Thompson - Sat, 8 May 2021 22:01 UTC

Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
> On 08/05/2021 13:53, hongy...@gmail.com wrote:
>> Gives nothing for my case on Ubuntu 20.04:
>>
>> werner@X10DAi:~$ which command-not-found
>> werner@X10DAi:~$
>
> What about:
>
> type command-not-found
>
> or
>
> type command_not_found_handle
>
> Is it a programs in Debian, but it could be a simple Bash function on
> Ubuntu.

I'm not sure why people (at least bash users) use "which" rather than
"type".

"which" is typically an external command (on my system it's a
/bin/sh script), which means it doesn't have access to functions or
aliases in the current shell process. "type" is, at least in bash,
a shell builtin, with options to do pretty much any useful thing
you'd want it to. It's also likely to be faster, though probably
not noticeably so. (I used "which" back when I was a csh user,
and the more powerful "where" when I switched to tcsh. Both are
shell builtins in tcsh, but not in bash.)

"type command-not-found" doesn't find anything on my
system, and the reason is straightforward. bash recognizes
"command_not_found_handle" as the name of a shell function
to be invoked when a command is not found. The default
implementation executes "/usr/lib/command-not-found" if it exists.
Since /usr/lib is unlikely to be in your $PATH, neither "type
command-not-found" nor "which command-not-found" is going to find it.
(/usr/lib/command-not-found happens to be a Python script on
my system.)

That's on Ubuntu 20.04. On the Debian 10 system where I
have an account, command_not_found_handle is not defined and
/usr/lib/command-not-found doesn't exist -- probably just because
the command-not-found package is not installed.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

Re: Non-installed programs and installation hints (from shell?)

<888f4ebc-e890-4823-94ca-72c2fdc269abn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3738&group=comp.unix.shell#3738

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:1309:: with SMTP id v9mr15995715qtk.133.1620520118854;
Sat, 08 May 2021 17:28:38 -0700 (PDT)
X-Received: by 2002:ac8:6c48:: with SMTP id z8mr15412574qtu.219.1620520118643;
Sat, 08 May 2021 17:28:38 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 8 May 2021 17:28:38 -0700 (PDT)
In-Reply-To: <s766m2$aor$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=211.23.211.42; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 211.23.211.42
References: <s737e4$8hd$1@news-1.m-online.net> <c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
<s75j00$6d5$1@dont-email.me> <e7d7e32d-69f7-42c8-8b40-7803f0c833c4n@googlegroups.com>
<s766m2$aor$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <888f4ebc-e890-4823-94ca-72c2fdc269abn@googlegroups.com>
Subject: Re: Non-installed programs and installation hints (from shell?)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 09 May 2021 00:28:38 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2333
 by: hongy...@gmail.com - Sun, 9 May 2021 00:28 UTC

On Saturday, May 8, 2021 at 10:19:51 PM UTC+8, Ottavio Caruso wrote:
> On 08/05/2021 13:53, hongy...@gmail.com wrote:
> > Gives nothing for my case on Ubuntu 20.04:
> >
> > werner@X10DAi:~$ which command-not-found
> > werner@X10DAi:~$
> What about:
>
> type command-not-found
>
> or
>
> type command_not_found_handle
>
> Is it a programs in Debian, but it could be a simple Bash function on
> Ubuntu.

Really, see below:

werner@X10DAi:~$ 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
}

>
> --
> Ottavio Caruso

Re: Non-installed programs and installation hints (from shell?)

<ea2d51a0-97ea-4b33-aaf7-6a7a232a0742n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3739&group=comp.unix.shell#3739

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:100e:: with SMTP id d14mr16174482qte.143.1620520293537;
Sat, 08 May 2021 17:31:33 -0700 (PDT)
X-Received: by 2002:ac8:6044:: with SMTP id k4mr16133393qtm.374.1620520293376;
Sat, 08 May 2021 17:31:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 8 May 2021 17:31:33 -0700 (PDT)
In-Reply-To: <87r1ig996l.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=103.142.140.222; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 103.142.140.222
References: <s737e4$8hd$1@news-1.m-online.net> <c95feb22-a159-4de2-98e5-f5e4b6817acdn@googlegroups.com>
<s75j00$6d5$1@dont-email.me> <e7d7e32d-69f7-42c8-8b40-7803f0c833c4n@googlegroups.com>
<s766m2$aor$1@dont-email.me> <87r1ig996l.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ea2d51a0-97ea-4b33-aaf7-6a7a232a0742n@googlegroups.com>
Subject: Re: Non-installed programs and installation hints (from shell?)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 09 May 2021 00:31:33 +0000
Content-Type: text/plain; charset="UTF-8"
 by: hongy...@gmail.com - Sun, 9 May 2021 00:31 UTC

On Sunday, May 9, 2021 at 6:01:43 AM UTC+8, Keith Thompson wrote:
> Ottavio Caruso <ottavio2006...@yahoo.com> writes:
> > On 08/05/2021 13:53, hongy...@gmail.com wrote:
> >> Gives nothing for my case on Ubuntu 20.04:
> >>
> >> werner@X10DAi:~$ which command-not-found
> >> werner@X10DAi:~$
> >
> > What about:
> >
> > type command-not-found
> >
> > or
> >
> > type command_not_found_handle
> >
> > Is it a programs in Debian, but it could be a simple Bash function on
> > Ubuntu.
> I'm not sure why people (at least bash users) use "which" rather than
> "type".
>
> "which" is typically an external command (on my system it's a
> /bin/sh script), which means it doesn't have access to functions or
> aliases in the current shell process. "type" is, at least in bash,
> a shell builtin, with options to do pretty much any useful thing
> you'd want it to. It's also likely to be faster, though probably
> not noticeably so. (I used "which" back when I was a csh user,
> and the more powerful "where" when I switched to tcsh. Both are
> shell builtins in tcsh, but not in bash.)
>
> "type command-not-found" doesn't find anything on my
> system, and the reason is straightforward. bash recognizes
> "command_not_found_handle" as the name of a shell function
> to be invoked when a command is not found. The default
> implementation executes "/usr/lib/command-not-found" if it exists.
> Since /usr/lib is unlikely to be in your $PATH, neither "type
> command-not-found" nor "which command-not-found" is going to find it.
> (/usr/lib/command-not-found happens to be a Python script on
> my system.)
>
> That's on Ubuntu 20.04. On the Debian 10 system where I
> have an account, command_not_found_handle is not defined and
> /usr/lib/command-not-found doesn't exist -- probably just because
> the command-not-found package is not installed.

You can check it with the following command:

$ dpkg --get-selections |grep command-not-found
command-not-found install

>
> --
> Keith Thompson (The_Other_Keith) Keith.S.T...@gmail.com
> Working, but not speaking, for Philips Healthcare
> void Void(void) { Void(); } /* The recursive call of the void */

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor