aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Lisina <sekoohaka.sarisan@gmail.com>2025-10-14 04:56:27 +0500
committerMaria Lisina <sekoohaka.sarisan@gmail.com>2025-10-14 04:56:27 +0500
commit83f54d151041bc5b03e8f4f7622396ce282df7cf (patch)
tree71bb0468e8d053c80934a1dfb4fad59610db0b58
parent6aa03562b00e49727bc03f1dd2f4853efd613658 (diff)
lists: Remove unnecessary if statements
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
-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}"