Skip to content

Commit

Permalink
eread: Fix bash error when the elog directory is empty
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fuzzyray committed Oct 17, 2016
1 parent 7b5c017 commit b5e71f6
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions bin/eread
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b5e71f6

Please sign in to comment.