minor bug fix

pull/1385/head
Gurkirat Singh 2019-06-08 03:14:37 +05:30
parent b97818b976
commit 50a2f1522e
1 changed files with 5 additions and 5 deletions

View File

@ -6,13 +6,13 @@ about-plugin '/etc/hosts based operations'
___HOST_FILE="/etc/hosts" ___HOST_FILE="/etc/hosts"
function ___hosts_add { function ___hosts_add {
local ENTRY=`grep "$2" $_HOST_FILE` local ENTRY=`grep "$2" $___HOST_FILE`
if [[ $ENTRY != "" ]] if [[ $ENTRY != "" ]]
then then
echo "Host "$2" already added" echo "Host "$2" already added"
echo $ENTRY echo $ENTRY
else else
echo "$1 $2" | sudo tee -a /etc/hosts > /dev/null echo "$1 $2" | sudo tee -a $___HOST_FILE > /dev/null
echo "Added $1 $2 to hosts file" echo "Added $1 $2 to hosts file"
exit 1 exit 1
fi fi
@ -23,11 +23,11 @@ function ___hosts_list {
} }
function ___hosts_remove { function ___hosts_remove {
local ENTRY=`grep "$1" $_HOST_FILE` local ENTRY=`grep "$1" $___HOST_FILE`
if [[ $ENTRY != "" ]] if [[ $ENTRY != "" ]]
then then
DELETED=`grep -w -v $1 $_HOST_FILE` DELETED=`grep -w -v $1 $___HOST_FILE`
echo "$DELETED" | sudo tee /etc/hosts > /dev/null echo "$DELETED" | sudo tee $___HOST_FILE > /dev/null
echo "Removed \""$ENTRY"\" from hosts file" echo "Removed \""$ENTRY"\" from hosts file"
else else
echo "Host "$1" not found" echo "Host "$1" not found"