From 0c572c6f446d29132f2927152298845b5f28c260 Mon Sep 17 00:00:00 2001 From: James Moore Date: Fri, 15 Mar 2013 14:44:45 -0700 Subject: [PATCH] add a newline to hosts if it doesn't have one at the end. Should take care of https://github.com/pgib/virtualhost.sh/issues/9 --- virtualhost.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/virtualhost.sh b/virtualhost.sh index cb03019..a09672b 100755 --- a/virtualhost.sh +++ b/virtualhost.sh @@ -700,6 +700,11 @@ esac if ! checkyesno ${SKIP_ETC_HOSTS}; then if ! host_exists $VIRTUALHOST ; then + x=$(tail -c 1 /etc/hosts) + if [ "$x" != "" ] + then echo >> /etc/hosts + fi + /bin/echo "Creating a virtualhost for $VIRTUALHOST..." /bin/echo -n "+ Adding $VIRTUALHOST to /etc/hosts... " /bin/echo "$IP_ADDRESS $1" >> /etc/hosts