[SM-Commit] BZR Change 24 to devel sorcery by Andrew Stitt <astitt at sourcemage.org>

scm at mail.sourcemage.org scm at mail.sourcemage.org
Sun Apr 23 21:50:03 EDT 2006


------------------------------------------------------------
revno: 24
committer: Andrew Stitt <astitt at sourcemage.org>
branch nick: devel-hack4
timestamp: Sun 2006-04-23 18:48:18 -0700
message:
  fix bug 8070, make changelog viewing timeout

=== modified file 'ChangeLog'
--- ChangeLog	
+++ ChangeLog	
@@ -1,3 +1,8 @@
+2006-04-23 Andrew Stitt <astitt at sourcemage.org>
+	* libsorcery: fix bug 8070, add pager timeout for changelog viewing
+	* config: add a pager timeout, and use less -F instead of -E,
+	  see if people like -F better than -E.
+
 2006-04-23 Andrew Stitt <astitt at sourcemage.org>
 	* libsummon: fix bug 9415, do some sanity checking in summon
 

=== modified file 'etc/sorcery/config'
--- etc/sorcery/config	
+++ etc/sorcery/config	
@@ -19,6 +19,7 @@
          VIEW_REPORTS=${VIEW_REPORTS:=on}
                VOYEUR=${VOYEUR:=on}
          PROMPT_DELAY=${PROMPT_DELAY:=150}
+        PAGER_TIMEOUT=${PAGER_TIMEOUT:=150}
            MAX_CABALS=${MAX_CABALS:=16}
            NET_SELECT=${NET_SELECT:=off}
             MD5SUM_DL=${MD5SUM_DL:=ask_risky}
@@ -52,7 +53,7 @@
                     # -X: dont do screen init and deinit, gaze install
                     # of a small spell is effectively useless otherwise as the
                     # screen is cleared afterwards.
-                PAGER=${PAGER:=less -R -E -X -f}
+                PAGER=${PAGER:=less -R -F -X -f}
              FILEPROG=${FILEPROG:=file}
            DIALOGPROG=${DIALOGPROG:=dialog}
 

=== modified file 'var/lib/sorcery/modules/libsorcery'
--- var/lib/sorcery/modules/libsorcery	
+++ var/lib/sorcery/modules/libsorcery	
@@ -951,7 +951,6 @@
 ##
 #---------------------------------------------------------------------
 function get_new_changes() {
-    local PAGER2="$(override_pager)"
     local msg="$1"
     local date="$2"
     # This needs some explaination:
@@ -981,7 +980,9 @@
         echo "$msg"
         echo
         echo "$changelog"
-      } | $PAGER2
+      }  > $TMP_DIR/pagerdata
+      timeout_pager "$TMP_DIR/pagerdata"
+      rm $TMP_DIR/pagerdata
     else
       echo "$msg"
       echo
@@ -989,9 +990,26 @@
     fi
 }
 
-function override_pager() {
-  #placeholder for a proper fix for http://bugs.sourcemage.org/show_bug.cgi?id=8070
-  if [ "$PAGER" == "less" ]; then echo "more"; else echo "$PAGER"; fi
+
+#---------------------------------------------------------------------
+## Pager with timeouts, cannot be used from a pipe.
+## Invokes a subshell in case there are other background jobs running
+#---------------------------------------------------------------------
+function timeout_pager() { (
+  $PAGER "$@" &
+  sleep 1
+  for ((i=0;i<PAGER_TIMEOUT*10;i++)) ; do
+    jobs &>/dev/null # this makes bash clean up so the next line works
+    [[ "$(jobs)" ]] || return 0
+    sleep .1
+  done
+  jobs -p|xargs kill
+  jobs &>/dev/null # hide the [Done [2] blah blah] message
+  stty sane
+  if query "\nPager timeout, continue viewing $@" n; then
+    $PAGER "$@"
+  fi
+) 2>/dev/null # hides less complaining that it was killed
 }
 
 #---------------------------------------------------------------------




More information about the SM-Commit mailing list