Jas*_*ick 3 command-line which tcsh
为什么 Linux 程序which
要求您刷新 shell(例如tcsh
在终端中键入)以查看安装在您路径中的新程序??
我很困惑为什么我无法访问一个程序,该程序与 中的其他程序具有相同的权限usr/local/bin
,which
可以清楚地看到。
有人可以用外行的话向我解释这是如何工作的吗?
尝试 rehash
man tcsh
说
rehash Causes the internal hash table of the contents of the directo-
ries in the path variable to be recomputed. This is needed if
new commands are added to directories in path while you are
logged in. This should be necessary only if you add commands
to one of your own directories, or if a systems programmer
changes the contents of one of the system directories. Also
flushes the cache of home directories built by tilde expansion.
Run Code Online (Sandbox Code Playgroud)
通俗地说:tcsh 想要提供快速响应,因此它构建了一个内部命令表(大概是一个哈希表)以及它们的位置。它大概是在启动时执行此操作。不幸的是,它没有任何机制来通知您或管理员何时执行需要更新该表的操作。
这是我更喜欢 ksh 或 bash 而非 csh 衍生产品的众多原因之一。