commit:     b5e71f6f2ed3483422df611fc2450081c72332ac
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 17 17:38:09 2016 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 17:38:09 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b5e71f6f

eread: Fix bash error when the elog directory is empty

This fixes the following error from bash which causes an infinite loop.

/usr/bin/eread: line 64: break: only meaningful in a `for', `while', or
`until' loop

X-Gentoo-bug: 597132
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=597132

 bin/eread | 124 +++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/bin/eread b/bin/eread
index fe095a6..2289f2d 100755
--- a/bin/eread
+++ b/bin/eread
@@ -57,72 +57,72 @@ find_files() {
 }
 
 select_loop() {
-       ANY_FILES=$(find_files)
-
-       if [[ -z ${ANY_FILES} ]]; then
-               echo "No log items to read"
-               break
-       fi
-
-       echo
-       echo "This is a list of portage log items. Choose a number to view that 
file or type q to quit."
-       echo
-
-       # Pick which file to read
-       select FILE in ${ANY_FILES}; do
-               case ${REPLY} in
-                       q)
-                               echo "Quitting"
-                               QUIT="yes"
-                               break
-                               ;;
-                       a)
-                               SORT="alphabet"
-                               ;;
-                       t)
-                               SORT="time"
-                               ;;
-                       *)
-                               if [ -f "$FILE" ]; then
-                                       ${PAGER} ${FILE}
-                                       read -p "Delete file? [y/N] " DELETE
-                                       case ${DELETE} in
-                                               q)
-                                                       echo "Quitting"
-                                                       QUIT="yes"
-                                                       break
-                                                       ;;
-                                               y|Y)
-                                                       rm -f ${FILE}
-                                                       SUCCESS=$?
-                                                       if [[ ${SUCCESS} = 0 
]]; then
-                                                               echo "Deleted 
${FILE}"
-                                                       else
-                                                               echo "Unable to 
delete ${FILE}"
-                                                       fi
-                                                       ;;
-                                               # Empty string defaults to N 
(save file)
-                                               n|N|"")
-                                                       echo "Saving ${FILE}"
-                                                       ;;
-                                               *)
-                                                       echo "Invalid response. 
Saving ${FILE}"
-                                                       ;;
-                                       esac
-                               else
-                                       echo
-                                       echo "Invalid response."
-                               fi
-                               ;;
-               esac
-               break
+       until [[ -n ${QUIT} ]]; do
+               ANY_FILES=$(find_files)
+
+               if [[ -z ${ANY_FILES} ]]; then
+                       echo "No log items to read"
+                       break
+               fi
+
+               echo
+               echo "This is a list of portage log items. Choose a number to 
view that file or type q to quit."
+               echo
+
+               # Pick which file to read
+               select FILE in ${ANY_FILES}; do
+                       case ${REPLY} in
+                               q)
+                                       echo "Quitting"
+                                       QUIT="yes"
+                                       break
+                                       ;;
+                               a)
+                                       SORT="alphabet"
+                                       ;;
+                               t)
+                                       SORT="time"
+                                       ;;
+                               *)
+                                       if [ -f "$FILE" ]; then
+                                               ${PAGER} ${FILE}
+                                               read -p "Delete file? [y/N] " 
DELETE
+                                               case ${DELETE} in
+                                                       q)
+                                                               echo "Quitting"
+                                                               QUIT="yes"
+                                                               break
+                                                               ;;
+                                                       y|Y)
+                                                               rm -f ${FILE}
+                                                               SUCCESS=$?
+                                                               if [[ 
${SUCCESS} = 0 ]]; then
+                                                                       echo 
"Deleted ${FILE}"
+                                                               else
+                                                                       echo 
"Unable to delete ${FILE}"
+                                                               fi
+                                                               ;;
+                                                       # Empty string defaults 
to N (save file)
+                                                       n|N|"")
+                                                               echo "Saving 
${FILE}"
+                                                               ;;
+                                                       *)
+                                                               echo "Invalid 
response. Saving ${FILE}"
+                                                               ;;
+                                               esac
+                                       else
+                                               echo
+                                               echo "Invalid response."
+                                       fi
+                                       ;;
+                       esac
+                       break
+               done
        done
 }
 
 pushd ${ELOGDIR} > /dev/null
 
-until [[ -n ${QUIT} ]]; do
-       select_loop
-done
+select_loop
 
 popd > /dev/null

Reply via email to