On Wed, Apr 14, 2021 at 12:19:47PM +0000, Curt wrote: > I was going to snidely inquire who in their right mind would create an > executable called 'command-not-found', but then: > > curty@einstein:~$ apt-cache show command-not-found > > ... > > Description-en: Suggest installation of packages in interactive bash sessions > This package will install handler for command_not_found that looks up > programs not currently installed but available from the repositories. > > Does this mean if you type 'blender' (a package available in the repositories) > at the command line and don't happen to have blender installed, > 'command-not-found' will somehow intervene to suggest installing it? (Question > purely rhetorical (unless you'd want to answer it).)
Bash has a feature that permits the creation of a function named command_not_found_handle. If such a function exists, then instead of giving the simple, traditional "bash: foobar: command not found" message, bash will instead execute that function. unicorn:~$ foobar bash: foobar: command not found unicorn:~$ command_not_found_handle() { echo "I'm a little teapot"; } unicorn:~$ foobar I'm a little teapot Apparently the intent of this is to make the user's life better, but in practice I'm not sure that's how it usually plays out. I believe Ubuntu installs such a function in every user's bash sessions by default, and uses it to try to tell the user which package they would have to install to get the command they were trying to use. In some cases, I can see how that might be useful. But sometimes, a command isn't found because the user made a typo, or because the user has absolutely no clue what they're doing, and then the results are just confusing.