mer*_*att 5 bash shell sh file-not-found vagrant
我在下面的代码中Vagrantfile调用了以下脚本.脚本运行正常,直到最后一行source $dotfile.source脚本说,当它到达时source: not found.以前的行,cat $dotfile工作得很好,所以文件显然存在.
为什么这个文件找不到该source命令,但它适用于上一个cat命令?
output error
==> default: /vagrant/scripts/create_functions_dotfile.sh: 14: /vagrant/scripts/create_functions_dotfile.sh: source: not found
Run Code Online (Sandbox Code Playgroud)
Vagrantfile
config.vm.provision "#{script["name"]}", type: "shell" do |shell|
shell.inline = "/bin/sh /vagrant/scripts/create_functions_dotfile.sh"
end
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
来源特定于#!/ bin/bash,所以要么你
替代
#!/bin/sh
Run Code Online (Sandbox Code Playgroud)
同
#!/bin/bash
Run Code Online (Sandbox Code Playgroud)替代
source $dotfile
Run Code Online (Sandbox Code Playgroud)
同
. $dotfile
Run Code Online (Sandbox Code Playgroud)ETA:事实上,错误抱怨找不到"来源",而不是其论点.
| 归档时间: |
|
| 查看次数: |
1242 次 |
| 最近记录: |