Skip to content

Commit

Permalink
chore: Use "true" instead of "y" when setting variables
Browse files Browse the repository at this point in the history
While "y" may usually be accepted as a valid boolean value, "true" is more standard and meaningful.

To be fair, the actual value of the variables doesn't matter as I use conditionals based on whether the variable is empty or not.
Still, "true" is more conventional.
  • Loading branch information
Antiz96 committed Sep 25, 2024
1 parent 6cd2ddd commit fb589ee
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ case "${option}" in
;;
-l|--list)
# Set that the "-l/--list" option is used (required for the "list_packages" library to only print the list of packages available for update without asking for the user confirmation to apply them)
list_option="y"
list_option="true"

# Source the "list_packages" library which displays the list of packages available for updates
# shellcheck source=src/lib/list_packages.sh
source "${libdir}/list_packages.sh"
;;
-n|--news)
# Set that news should be shown and that the "-n/--news" option is used (required for the "list_news" library to only print the list of recent Arch news without looking to continue with the update process)
show_news="y"
news_option="y"
show_news="true"
news_option="true"

# Check if the user specified a specific number of news to display
if [ "${2}" -gt 0 ] 2> /dev/null; then
Expand Down
6 changes: 3 additions & 3 deletions src/lib/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ config_file="${XDG_CONFIG_HOME:-${HOME}/.config}/${name}/${name}.conf"
if [ -f "${config_file}" ]; then
# Check the "NoColor" option in arch-update.conf
# shellcheck disable=SC2034
no_color=$(grep -Eq '^[[:space:]]*NoColor[[:space:]]*$' "${config_file}" 2> /dev/null && echo "y")
no_color=$(grep -Eq '^[[:space:]]*NoColor[[:space:]]*$' "${config_file}" 2> /dev/null && echo "true")

# Check the "NoVersion" option in arch-update.conf
# shellcheck disable=SC2034
no_version=$(grep -Eq '^[[:space:]]*NoVersion[[:space:]]*$' "${config_file}" 2> /dev/null && echo "y")
no_version=$(grep -Eq '^[[:space:]]*NoVersion[[:space:]]*$' "${config_file}" 2> /dev/null && echo "true")

# Check the "AlwaysShowNews" option in arch-update.conf
# shellcheck disable=SC2034
show_news=$(grep -Eq '^[[:space:]]*AlwaysShowNews[[:space:]]*$' "${config_file}" 2> /dev/null && echo "y")
show_news=$(grep -Eq '^[[:space:]]*AlwaysShowNews[[:space:]]*$' "${config_file}" 2> /dev/null && echo "true")

# Check the "NewsNum" option in arch-update.conf
# shellcheck disable=SC2034
Expand Down
4 changes: 2 additions & 2 deletions src/lib/list_news.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else
echo "${news}" | htmlq -a title a | grep ^"View:" | sed "s/View:\ //g" | head -1 > "${statedir}/current_news_check"

if ! diff "${statedir}/current_news_check" "${statedir}/last_news_check" &> /dev/null; then
show_news="y"
show_news="true"
else
echo
info_msg "$(eval_gettext "No recent Arch News found")"
Expand Down Expand Up @@ -67,7 +67,7 @@ else

for num in "${answer_array[@]}"; do
if [ "${num}" -le "${news_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then
printed_news="y"
printed_news="true"
news_selected=$(sed -n "${num}"p <<< "${news_titles}")
news_path=$(echo "${news_selected}" | sed s/\ -//g | sed s/\ /-/g | sed s/[.]//g | sed s/=//g | sed s/\>//g | sed s/\<//g | sed s/\`//g | sed s/://g | sed s/+//g | sed s/[[]//g | sed s/]//g | sed s/,//g | sed s/\(//g | sed s/\)//g | sed s/[/]//g | sed s/@//g | sed s/\'//g | sed s/--/-/g | awk '{print tolower($0)}')
news_url="https://www.archlinux.org/news/${news_path}"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/list_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ else
case "${answer}" in
"$(eval_gettext "Y")"|"$(eval_gettext "y")"|"")
# shellcheck disable=SC2034,SC2154
proceed_with_update="y"
proceed_with_update="true"
echo
;;
*)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/restart_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ if [ -n "${packages_updated}" ]; then

for num in "${answer_array[@]}"; do
if [ "${num}" -le "${services_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then
service_restarted="y"
service_restarted="true"
service_selected=$(sed -n "${num}"p <<< "${services}")

if "${su_cmd}" systemctl restart "${service_selected}"; then
info_msg "$(eval_gettext "The \${service_selected} service has been successfully restarted")"
else
error_msg "$(eval_gettext "An error has occurred during the restart of the \${service_selected} service")"
service_fail="y"
service_fail="true"
fi
fi
done
Expand Down
4 changes: 2 additions & 2 deletions src/lib/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ -n "${packages}" ]; then
error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg
exit 5
else
packages_updated="y"
packages_updated="true"
fi
fi

Expand All @@ -31,7 +31,7 @@ if [ -n "${aur_packages}" ]; then
exit 5
else
# shellcheck disable=SC2034
packages_updated="y"
packages_updated="true"
fi
fi

Expand Down

0 comments on commit fb589ee

Please sign in to comment.