ubuntuのcommand_not_found_handle
ubuntuは入力したcommandが見つからない、かつそのcommandがaptで用意されているときに、apt-getしたら入るよ、と教えてくれる。
$ sl The program 'sl' is currently not installed. You can install it by typing: sudo apt-get install sl -bash: sl: command not found
どやってるのかな?と思って環境変数とかmanとか見てたら、debianの拡張らしいすね。
- man bash
command_not_found_handle The name of a shell function to be called if a command cannot be found. The return value of this function should be 0, if the command is available after execution of the function, otherwise 127 (EX_NOTFOUND). Enabled only in interactive, non POSIX mode shells. This is a Debian extension.
$ set
(略)
command_not_found_handle ()
{
if [ -x /usr/lib/command-not-found ]; then
/usr/bin/python /usr/lib/command-not-found -- $1;
return $?;
else
return 127;
fi
}
$ file /usr/lib/command-not-found
/usr/lib/command-not-found: python script text executable