挙動からそういう動きがあるとは思いつつ放ってましたが、ふとどこでその処理をやっているか考えてみたら、そうか bash が何かやっているに違いないと思い。set を打ったところ、次のような関数が設定されていることに気がつきました。
[root@fedora14 ~]# set ... command_not_found_handle () { runcnf=1; retval=127; [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0; [ ! -x /usr/libexec/packagekitd ] && runcnf=0; if [ $runcnf -eq 1 ]; then /usr/libexec/pk-command-not-found $@; retval=$?; else echo "bash: $1: command not found"; fi; return $retval }この関数を unset command_not_found_handle すれば、ネットアクセスを停止できます。.bashrc にでも書いておけばよい。いったいどこでこの設定が行われているか探ってみると、次の場所でした。
[root@fedora14 ~]# grep -r command_not_found_handle /etc /etc/profile.d/PackageKit.sh:command_not_found_handle () {なお、未インストールのコマンドを打った場合、次のように便利に機能することもあります。
[root@fedora14 ~]# resize bash: resize: command not found... Install package 'xterm' to provide command 'resize'? [N/y] * Running.. * Resolving dependencies.. * Downloading update information.. * Waiting for authentication.. * Waiting in queue.. * Resolving dependencies.. * Downloading packages.. * Testing changes.. * Installing packages.. * Scanning applications.. COLUMNS=80; LINES=34; export COLUMNS LINES;
2011-03-07追記
bash のオンラインマニュアルに次のような記述があります。
COMMAND EXECUTION After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken. If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, that function is invoked as described above in FUNCTIONS. If the name does not match a function, the shell searches for it in the list of shell builtins. If a match is found, that builtin is invoked. If the name is neither a shell function nor a builtin, and contains no slashes, bash searches each element of the PATH for a directory containing an executable file by that name. Bash uses a hash table to remember the full pathnames of executable files (see hash under SHELL BUILTIN COMMANDS below). A full search of the directories in PATH is performed only if the command is not found in the hash table. 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 with the original command and the original command's arguments as its arguments, and the function's exit status becomes the exit status of the shell. If that function is not defined, the shell prints an error message and returns an exit status of 127.
0 件のコメント:
コメントを投稿