我有一个按惯例/usr/bin/vendor/
添加到其中的文件夹,其中PATH
包含例如shell脚本do_something.sh
。现在,我想添加一个子文件夹,/usr/bin/vendor/some_tool/
以另外存储分组在一起的一个或多个Perl脚本,因为它们具有相同的用途,并且我还需要另外管理Eclipse项目文件,甚至可能是配置文件等。最后,我可能会得到/usr/bin/vendor/some_tool/do_a.pl
和/usr/bin/vendor/some_tool/do_b.pl
。
由于PATH
,我可以轻松地do_something.sh
在任何地方调用。但是,有什么方法可以调用some_tool/do_a.pl
相同的方法吗?真正some_tool/do_a.pl
与相对路径,让我知道我在做任务do_a
的some_tool
。我想使用相对目录结构来实现一个措辞/命名约定。
在外壳上尝试了一下,它当然没有用,但是也许我做错了,它应该可以正常工作。但是我猜应该不行,唯一的解决方法是创建一个/usr/bin/vendor/some_tool_do_a.sh
将所有args转发到的文件/usr/bin/vendor/some_tool/do_a.pl
。
该bash
手册页指定
PATH The search path for commands. It is a colon-separated list of
directories in which the shell looks for commands (see COMMAND
EXECUTION below).
然后继续说
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 con‐
taining an executable file by that name.
因此,答案似乎是“不,您不想要做的事bash
。”
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句