问题描述
我在 Vagrantfile
它调用下面的脚本低于code。该脚本运行良好,直到最后一行源$ dotfile
。当它到达源
,剧本说来源:找不到
。前行,猫$ dotfile
工作得很好,因此该文件明显存在。
为什么这个文件不知何故未找到源
命令,但它的工作原理为previous 猫
命令?
输出误差
==>默认:/vagrant/scripts/create_functions_dotfile.sh:14:/vagrant/scripts/create_functions_dotfile.sh:来源:未找到
Vagrantfile
config.vm.provision#{脚本[名称]},键入:壳做|外壳|
shell.inline =/ bin / sh的/vagrant/scripts/create_functions_dotfile.sh
结束
脚本/ create_functions_dotfile.sh
#!/ bin / sh的dotfile = /家庭/流浪者/ .functions.sh在/文件游民/脚本/功能/ *;做
回声猫$文件>> $ dotfile
猫$文件>> $ dotfile
DONE回声源$ dotfile>> /home/vagrant/.bashrc
猫$ dotfile
来源$ dotfile
来源是具体的#!/斌/ bash的,所以要么你
-
替代
#!/ bin / sh的
与
#!/斌/庆典
-
替代
来源$ dotfile
与
。 $ dotfile
ETA:作为事实上,错误抱怨说,源是找不到的,不是它的参数
I have the below code in my Vagrantfile
which calls the below script. The script runs fine up until the last line source $dotfile
. When it gets to source
, the script says source: not found
. The line before, cat $dotfile
works just fine so the file clearly exists.
Why is this file somehow not found for the source
command but it works for the previous cat
command?
output error
==> default: /vagrant/scripts/create_functions_dotfile.sh: 14: /vagrant/scripts/create_functions_dotfile.sh: source: not found
Vagrantfile
config.vm.provision "#{script["name"]}", type: "shell" do |shell|
shell.inline = "/bin/sh /vagrant/scripts/create_functions_dotfile.sh"
end
scripts/create_functions_dotfile.sh
#!/bin/sh
dotfile=/home/vagrant/.functions.sh
for file in /vagrant/scripts/functions/*; do
echo "cat $file >> $dotfile"
cat $file >> $dotfile
done
echo "source $dotfile" >> /home/vagrant/.bashrc
cat $dotfile
source $dotfile
Source is specific for #!/bin/bash, so either you
substitute
#!/bin/sh
with
#!/bin/bash
substitute
source $dotfile
with
. $dotfile
ETA: as a matter of fact, the error complains that 'source' is not found, not its argument.
这篇关于来源流浪了找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!