From 25c24071bc618a649cae704bc3ad6d6ed719f474 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 16 Oct 2017 11:26:59 +0530 Subject: [PATCH 1/2] 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. --- ynh-dev | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ynh-dev b/ynh-dev index 1dadcd4..57a2f69 100755 --- a/ynh-dev +++ b/ynh-dev @@ -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 From 4d7e3182fff7be77635293cc4f51cf85631fe1ae Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 16 Oct 2017 11:42:49 +0530 Subject: [PATCH 2/2] macOS/BSD: fix IP retrieval `\s` for matching spaces is a GNU-sed extension. The portable way is to use `[[:space]]` instead. --- ynh-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ynh-dev b/ynh-dev index 57a2f69..5ceed67 100755 --- a/ynh-dev +++ b/ynh-dev @@ -190,7 +190,7 @@ VERSION as stable, testing or unstable /!\ " vagrant up $VMNAME --provider virtualbox # Warn user about hosts file - IP_LINE="\s\s*${VMNAME}.vm.network\s\s*:private_network,\s*ip:\s*\"" + IP_LINE="[[:space:]]*${VMNAME}.vm.network[[:space:]]*:private_network,[[:space:]]*ip:[[:space:]]*\"" IP=$(grep "$IP_LINE" Vagrantfile | sed "s/${IP_LINE}//" | tr -d '"') echo "/!\ Please add '$IP $DOMAIN' to your /etc/hosts file /!\\" echo "sudo bash -c 'echo \"$IP $DOMAIN\" >> /etc/hosts'"