summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSÅ‚awomir Nizio <slawomir.nizio@sabayon.org>2012-04-26 00:50:57 +0200
committerPaul Varner <fuzzyray@gentoo.org>2012-04-25 22:31:07 -0500
commita6a159cd3f8c8a89eccbba57689623a747fea73f (patch)
tree0c842d3050c7939d35dc6cdb1c4102f675523089 /bin
parentFix eread to work on a prefix environment. (diff)
downloadgentoolkit-a6a159cd3f8c8a89eccbba57689623a747fea73f.tar.gz
gentoolkit-a6a159cd3f8c8a89eccbba57689623a747fea73f.tar.bz2
gentoolkit-a6a159cd3f8c8a89eccbba57689623a747fea73f.zip
Extend eread to allow sorting (bug 413577).
Diffstat (limited to 'bin')
-rwxr-xr-xbin/eread35
1 files changed, 33 insertions, 2 deletions
diff --git a/bin/eread b/bin/eread
index 7d0a970..d74a167 100755
--- a/bin/eread
+++ b/bin/eread
@@ -5,6 +5,7 @@
#
# Author: Donnie Berkholz <spyderous@gentoo.org>
# Updated by: Uwe Klosa <uwe.klosa@gmail.com>
+# Updated by: Slawomir Nizio <slawomir.nizio@sabayon.org>
# Get prefix
EPREFIX=${EPREFIX:-$(portageq envvar EPREFIX)}
@@ -30,9 +31,33 @@ fi
# Set up select prompt
PS3="Choice? "
+SORT=${EREAD_SORT_ORDER}
+
+find_unsorted() {
+ find . -type f | sed -e "s:\./::g"
+}
+find_by_name() {
+ find . -type f | sort | sed -e "s:\./::g"
+}
+find_by_time() {
+ find . -type f | sort -k 3 -t : | sed -e "s:\./::g"
+}
+find_files() {
+ case ${SORT} in
+ alphabet)
+ find_by_name
+ ;;
+ time)
+ find_by_time
+ ;;
+ *)
+ find_unsorted
+ ;;
+ esac
+}
+
select_loop() {
- ANY_FILES=$(find . -type f)
- ANY_FILES=$(echo ${ANY_FILES} | sed -e "s:\./::g")
+ ANY_FILES=$(find_files)
if [[ -z ${ANY_FILES} ]]; then
echo "No log items to read"
@@ -51,6 +76,12 @@ select_loop() {
QUIT="yes"
break
;;
+ a)
+ SORT="alphabet"
+ ;;
+ t)
+ SORT="time"
+ ;;
*)
if [ -f "$FILE" ]; then
${PAGER} ${FILE}