简体   繁体   English

使用 $BASH_SOURCE 变量时“没有这样的文件或目录”

[英]"No such file or directory" when using $BASH_SOURCE variable

I have a problem with a script using $BASH_SOURCE我有一个使用$BASH_SOURCE的脚本的问题

When I run the script with sudo ./install.sh in Ubuntu I get the following error ./home/parallels/Desktop/app/install.sh: No such file or directory当我在 Ubuntu 中使用sudo ./install.sh运行脚本时,出现以下错误./home/parallels/Desktop/app/install.sh: No such file or directory

It seams like it is the "."它接缝就像是“。” (dot) in front of the dirname that's causing the problem (点)在导致问题的目录名前面

I have also tried to use sudo su before running the script.我还尝试在运行脚本之前使用sudo su

The part of the script in question is the following:有问题的脚本部分如下:

repo_dir="`dirname "$BASH_SOURCE[0]" `/home/parallels/Desktop/app"
source $repo_dir/install.sh

Another thing I should mention is that it seems to work for others, so I wonder if it's the way I'm running the script or the placing of it.我应该提到的另一件事是它似乎对其他人有用,所以我想知道这是我运行脚本的方式还是放置它的方式。

Any help would be much appreciated任何帮助将非常感激

Thanks a lot for your help, it's very much appreciated.非常感谢您的帮助,非常感谢。 There has been an update from the developer, that apparently has had the same problem as me.开发人员有一个更新,显然和我有同样的问题。 The new line looks like this, and it works:新行看起来像这样,它有效:

repo_dir=" dirname "$BASH_SOURCE[0]"`/../../../" repo_dir="目录名"$BASH_SOURCE[0]"`/../../../"

source "$repo_dir/install.sh"`源“$repo_dir/install.sh”`

Thank you again.再次感谢你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM