macOS/BSD: fix Vagrantfile in-place editing

* Unlike GNU-sed, BSD-sed `-i` option requires an explicit backup
  extension.
* Newlines are difficult to get right on different versions of `sed`.

This commit replaces the `sed` invocation with `perl`. It does the same
job with almost the same syntax, but avoids portability issues.
This commit is contained in:
Pierre de La Morinerie 2017-10-16 11:26:59 +05:30
parent 40b22fb02d
commit 25c24071bc

View file

@ -175,12 +175,12 @@ elif [ "$1" = "run" ]; then
}
# Adapt vagrantfile
sed -i "/ ### END AUTOMATIC YNH-DEV ###/ i \\
config.vm.define \"${VMNAME}\" do |${VMNAME}| \
perl -i -pe "s| (### END AUTOMATIC YNH-DEV ###)|\
config.vm.define \"${VMNAME}\" do \|${VMNAME}\| \
\n ${VMNAME}.vm.box = \"${BOX_NAME}\" \
\n ${VMNAME}.vm.network :private_network, ip: \"${IP}\" \
\n end \
\n" ./Vagrantfile
\n \1|" ./Vagrantfile
}
# Run VM