Make shell script for loop shell agnostic
This commit is contained in:
parent
018def1858
commit
220f346d2b
@ -17,7 +17,7 @@ module Vagrant
|
||||
basename = name.split(".", 2)[0]
|
||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||
grep -w '#{name}' /etc/hosts || {
|
||||
for i in {1..#{loop_bound}}; do
|
||||
for i in #{[*1..loop_bound].join(' ')}; do
|
||||
grep -w "127.0.${i}.1" /etc/hosts || {
|
||||
echo "127.0.${i}.1 #{name} #{basename}" >> /etc/hosts
|
||||
break
|
||||
|
||||
@ -20,8 +20,8 @@ describe "Vagrant::Util::GuestHosts" do
|
||||
end
|
||||
|
||||
it "can add hostname to loopback interface" do
|
||||
subject.add_hostname_to_loopback_interface(comm, "test.end", 40)
|
||||
expect(comm.received_commands[0]).to match(/for i in {1..40}; do/)
|
||||
subject.add_hostname_to_loopback_interface(comm, "test.end", 4)
|
||||
expect(comm.received_commands[0]).to match(/for i in 1 2 3 4; do/)
|
||||
expect(comm.received_commands[0]).to match(/echo \"127.0.\${i}.1 test.end test\" >> \/etc\/hosts/)
|
||||
end
|
||||
end
|
||||
@ -35,8 +35,8 @@ describe "Vagrant::Util::GuestHosts" do
|
||||
end
|
||||
|
||||
it "can add hostname to loopback interface" do
|
||||
subject.add_hostname_to_loopback_interface(comm, "test.end", 40)
|
||||
expect(comm.received_commands[0]).to match(/for i in {1..40}; do/)
|
||||
subject.add_hostname_to_loopback_interface(comm, "test.end", 4)
|
||||
expect(comm.received_commands[0]).to match(/for i in 1 2 3 4; do/)
|
||||
expect(comm.received_commands[0]).to match(/echo \"127.0.\${i}.1 test.end test\" >> \/etc\/hosts/)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user