Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit bf792e0

Browse files
committed
Clean up stale records in /etc/hosts before adding new ones with the same host #80
- Prepending new records instead of appending
1 parent 6ee8f77 commit bf792e0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/host/configure_etc_hosts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ IFS=$'\n'
2020
for etc_hosts_record in $(bash "${devbox_dir}/scripts/host/get_etc_hosts_records.sh"); do
2121
if [[ -z "$(grep "${etc_hosts_record}" /etc/hosts)" ]]; then
2222
status "Adding '${etc_hosts_record}' to '/etc/hosts'"
23-
echo "${etc_hosts_record}" | sudo tee -a "/etc/hosts" 2> >(logError) > >(log)
23+
echo -e "${etc_hosts_record}\n$(cat /etc/hosts)" | sudo tee "/etc/hosts" 2> >(logError) > >(log)
2424
else
2525
warning "'${etc_hosts_record}' has already been added to '/etc/hosts' previously"
2626
fi

0 commit comments

Comments
 (0)