我有一个实用的构建脚本,它从各个特定于项目的构建脚本中调用,部署在构建服务器上。一切都很好,直到相对目录结构发生变化。也就是说:
trunk/
utilities/
imported.xml
some_resource_file
projectName/
importing.xml
这个很好用,但有时我们需要:
trunk/
importing.xml
utilities/
imported.xml
some_resource_file
projectName/
问题在于imported.xml
需要some_resource_file
,目前是通过引用../utilities/some_resource_file
来找到它的。这当然在第一种情况下起作用,因为工作目录是utilities
的同级目录。是否有一种简单的方法让
imported.xml
知道它所在的目录,类似于bash中的dirname $0
?还是我必须从导入脚本中注入这个信息?