From eca9a0d201208f93d8536dc4aaa139f9ad94a79c Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sun, 1 Sep 2024 10:36:22 +0800 Subject: [PATCH] list.sh: simplify We don't need to output an intermediate `LS_ERRORED` string to exit in case that `ls` errors out. --- Library/Homebrew/list.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/list.sh b/Library/Homebrew/list.sh index 563f375ba6..1535b0329b 100644 --- a/Library/Homebrew/list.sh +++ b/Library/Homebrew/list.sh @@ -31,7 +31,6 @@ homebrew-list() { tty=1 fi - local error_string="LS_ERRORED" if [[ -z "${cask}" && -d "${HOMEBREW_CELLAR}" ]] then if [[ -n "${tty}" && -z "${formula}" ]] @@ -40,11 +39,8 @@ homebrew-list() { fi local formula_output - formula_output="$(ls "${ls_args[@]}" "${HOMEBREW_CELLAR}" || echo "${error_string}")" - if [[ "${formula_output}" == "${error_string}" ]] - then - exit 1 - elif [[ -n "${formula_output}" ]] + formula_output="$(ls "${ls_args[@]}" "${HOMEBREW_CELLAR}")" || exit 1 + if [[ -n "${formula_output}" ]] then echo "${formula_output}" fi @@ -63,11 +59,8 @@ homebrew-list() { fi local cask_output - cask_output="$(ls "${ls_args[@]}" "${HOMEBREW_CASKROOM}" || echo "${error_string}")" - if [[ "${cask_output}" == "${error_string}" ]] - then - exit 1 - elif [[ -n "${cask_output}" ]] + cask_output="$(ls "${ls_args[@]}" "${HOMEBREW_CASKROOM}")" || exit 1 + if [[ -n "${cask_output}" ]] then echo "${cask_output}" fi