diff options
author | Paul Varner <fuzzyray@gentoo.org> | 2016-10-17 12:38:09 -0500 |
---|---|---|
committer | Paul Varner <fuzzyray@gentoo.org> | 2016-10-17 12:38:09 -0500 |
commit | b5e71f6f2ed3483422df611fc2450081c72332ac (patch) | |
tree | 0564374378fc6c6c123225bd90eff43bd09cfdc2 /bin | |
parent | gentoolkit/package.py: Fix dblink call py3 compatibility bug 575788 (diff) | |
download | gentoolkit-b5e71f6f2ed3483422df611fc2450081c72332ac.tar.gz gentoolkit-b5e71f6f2ed3483422df611fc2450081c72332ac.tar.bz2 gentoolkit-b5e71f6f2ed3483422df611fc2450081c72332ac.zip |
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
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/eread | 124 |
1 files changed, 62 insertions, 62 deletions
@@ -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 |