From 3420656fcde3d2a03057f322cd996448f7e51daa Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Fri, 20 Sep 2019 15:16:46 +0200 Subject: [PATCH] B OpenNebula/addon-context-linux#148: Fix missing newline on FreeBSD --- src/etc/one-context.d/net-15-hostname | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/etc/one-context.d/net-15-hostname b/src/etc/one-context.d/net-15-hostname index 5cbf3eb..cf43b5c 100755 --- a/src/etc/one-context.d/net-15-hostname +++ b/src/etc/one-context.d/net-15-hostname @@ -77,7 +77,8 @@ function update_hosts() { eval "${SED_I} -re \"s/^.*[[:space:]]${name}([[:space:]#].*|$)/${entry}/\" /etc/hosts" # create new entry elif [ -f /etc/hosts ]; then - eval "${SED_I} -e \"1s/^/${entry}\"$'\\\n/' /etc/hosts" + # In FreeBSD, sed doesn't interpret \n. We put a real newline. + eval "${SED_I} -e \"1s/^/${entry}\"$'\\\\\n/' /etc/hosts" else echo "${entry}" >>/etc/hosts fi