Verify that matching records have been found in `remove` before removing

This commit is contained in:
William Melody 2015-03-20 18:10:51 -07:00
parent 312f5909fa
commit c2ca24b459
1 changed files with 4 additions and 0 deletions

4
hosts
View File

@ -789,6 +789,10 @@ remove() {
exit 1
else
local target_records=$(sed -n "s/^\(.*${search_string}.*\)$/\1/p" "${HOSTS_PATH}")
if [[ -z ${target_records:-} ]]; then
printf "No matching records found.\n"
exit 1
fi
if ! _command_argv_includes "--force"; then
printf "Removing the following records:\n%s\n" "$target_records"
while true; do