From 83f54d151041bc5b03e8f4f7622396ce282df7cf Mon Sep 17 00:00:00 2001 From: Maria Lisina Date: Tue, 14 Oct 2025 04:56:27 +0500 Subject: lists: Remove unnecessary if statements Signed-off-by: Maria Lisina --- aliases.zsh | 12 ++---------- blacklist.zsh | 12 +++--------- whitelist.zsh | 12 +++--------- 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}" -- cgit v1.2.3