-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I hacked up a quick script this morning to handle the new elog scripts
in 2.1. Perhaps some of you can make use of it or help me improve it.

Thanks,
Donnie
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDqt2XXVaO67S1rtsRAlzuAJwJooVqex46LHMYcYTDx40kUn6/WgCgrlgr
KUC845ELqhXHZ5ZNs6PkUbQ=
=Z5KJ
-----END PGP SIGNATURE-----
#!/bin/bash

# This is a script to read portage log items from einfo, ewarn etc, new in the
# portage-2.1 series.
#
# Author: Donnie Berkholz <[EMAIL PROTECTED]>

# Set PORTAGE_TMPDIR
PORTAGE_TMPDIR=$(portageq envvar PORTAGE_TMPDIR)

# Set up select prompt
PS3="Choice? "

select_loop() {
        ANY_FILES=$(/usr/bin/find ${PORTAGE_TMPDIR}/elogs/ -type f)

        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."
        echo

        # Pick which file to read
        select FILE in ${PORTAGE_TMPDIR}/elogs/*; do
                case ${REPLY} in
                        q)
                                echo "Quitting"
                                QUIT="yes"
                                break
                                ;;
                        *)
                                /usr/bin/less ${FILE}
                                read -p "Delete file? [y/N] " DELETE
                                case ${DELETE} in
                                        q)
                                                echo "Quitting"
                                                QUIT="yes"
                                                break
                                                ;;
                                        y|Y)
                                                /usr/bin/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
                                ;;
                esac
                break
        done
}

until [[ -n ${QUIT} ]]; do
        select_loop
done

Reply via email to