Bash
設置 bash shell 選項“checkhash”是否真的提高了 bash 命令的性能?
**前提:**在修改的過程中
.bashrc
,瀏覽了shopt線上頁面的bash手冊中可以處理的不同shell選項shopt
,我遇到了選項checkhash
,根據描述:checkhash If this is set, Bash checks that a command found in the hash table exists before trying to execute it. If a hashed command no longer exists, a normal path search is performed.
問題:
- 這個選項有用嗎,即它是否提高了 bash 命令的性能?
- 如果是,為什麼將預設值設置為
off
?- 如果,不,為什麼首先存在該選項,它與舊硬體有關嗎?
我認為該設置應該改善使用者體驗,而不是“性能”。
當您移動或刪除執行檔時,它應該使您不必
hash -r
手動執行。比較:
bash$ mkdir -p first second; PATH=$PATH:first:second bash$ echo echo ok > first/ok; chmod 755 first/ok bash$ ok ok bash$ mv first/ok second/ok bash$ ok bash: first/ok: No such file or directory # Yet it's in the PATH! bash$ hash -r bash$ ok ok
相對
bash$ shopt -s checkhash bash$ mv second/ok first/ok bash$ ok ok bash$ mv first/ok second/ok bash$ ok ok bash$