aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xaliases.zsh12
-rwxr-xr-xblacklist.zsh12
-rwxr-xr-xwhitelist.zsh12
3 files changed, 8 insertions, 28 deletions
diff --git a/aliases.zsh b/aliases.zsh
index 8b63899..838d36f 100755
--- a/aliases.zsh
+++ b/aliases.zsh
@@ -129,11 +129,6 @@ fi
case "${action}" in
(list)
- if ! [[ -s "${list}" ]]
- then
- exit 0
- fi
-
list=($(< "${list}"))
while [[ ${#list} -ge 2 ]]
@@ -153,7 +148,7 @@ case "${action}" in
exit 1
fi
- if [[ -s "${list}" ]] && alias="$(grep -xe "${user_id} .*" "${list}")"
+ if alias="$(grep -xe "${user_id} .*" "${list}")"
then
alias_id="$(cut -d ' ' -f 2 <<< "${alias}")"
@@ -164,10 +159,7 @@ case "${action}" in
printf "%s %s\n" "${user_id}" "${alias_id}" >> "${list}"
;;
(del)
- if [[ -s "${list}" ]]
- then
- sed -i "/^${user_id} .*$/d" "${list}"
- fi
+ sed -i "/^${user_id} .*$/d" "${list}"
;;
(reset)
< "${list}.default" > "${list}"
diff --git a/blacklist.zsh b/blacklist.zsh
index 5b15c11..6335abd 100755
--- a/blacklist.zsh
+++ b/blacklist.zsh
@@ -129,13 +129,10 @@ fi
case "${action}" in
(list)
- if [[ -s "${list}" ]]
- then
- < "${list}"
- fi
+ < "${list}"
;;
(add)
- if [[ -s "${list}" ]] && grep -qxe "${user_id}" "${list}"
+ if grep -qxe "${user_id}" "${list}"
then
echo "User ID ${user_id} is already in blacklist"
exit 1
@@ -144,10 +141,7 @@ case "${action}" in
printf "%s\n" "${user_id}" >> "${list}"
;;
(del)
- if [[ -s "${list}" ]]
- then
- sed -i "/^${user_id}$/d" "${list}"
- fi
+ sed -i "/^${user_id}$/d" "${list}"
;;
(reset)
< "${list}.default" > "${list}"
diff --git a/whitelist.zsh b/whitelist.zsh
index 9032eca..3f72c55 100755
--- a/whitelist.zsh
+++ b/whitelist.zsh
@@ -129,13 +129,10 @@ fi
case "${action}" in
(list)
- if [[ -s "${list}" ]]
- then
- < "${list}"
- fi
+ < "${list}"
;;
(add)
- if [[ -s "${list}" ]] && grep -qxe "${user_id}" "${list}"
+ if grep -qxe "${user_id}" "${list}"
then
echo "User ID ${user_id} is already in whitelist"
exit 1
@@ -144,10 +141,7 @@ case "${action}" in
printf "%s\n" "${user_id}" >> "${list}"
;;
(del)
- if [[ -s "${list}" ]]
- then
- sed -i "/^${user_id}$/d" "${list}"
- fi
+ sed -i "/^${user_id}$/d" "${list}"
;;
(reset)
< "${list}.default" > "${list}"