如何使用父路径映射到PATH的相对路径调用脚本?

托斯滕·舍宁

我有一个按惯例/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_asome_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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章