From f13a04c1252a757ad8a1d957aa36dfeadfe22aa6 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 27 Jan 2011 09:47:52 -0600 Subject: [PATCH] * A set of fixes for LP: #700911 * usr/bin/byobu-status, usr/bin/byobu-status-detail: - improve support for byobu-status-detail on systems without vim * usr/lib/byobu/mail: test for mail dir, avoids errors * usr/lib/byobu/reboot_required: test for file existence, avoids errors * usr/lib/byobu/wifi_quality: avoid potential divide by zero error --- debian/changelog | 11 +++++++++++ usr/bin/byobu-status | 5 ++++- usr/bin/byobu-status-detail | 13 +++++-------- usr/lib/byobu/mail | 2 +- usr/lib/byobu/reboot_required | 3 ++- usr/lib/byobu/wifi_quality | 9 +++++++-- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/debian/changelog b/debian/changelog index fd67b616..8ebe1476 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,21 @@ byobu (3.26) unreleased; urgency=low + [ Dustin Kirkland ] * usr/bin/byobu-reconnect-sockets, usr/lib/byobu/date, usr/share/byobu/keybindings/f-keys, usr/share/byobu/keybindings/screen-escape-keys: - add a ctrl-f5 keybinding for reconnecting sockets + [ swalker ] + * A set of fixes for LP: #700911 + * usr/bin/byobu-status, usr/bin/byobu-status-detail: + - improve support for byobu-status-detail on systems without vim + * usr/lib/byobu/mail: test for mail dir, avoids errors + * usr/lib/byobu/reboot_required: test for file existence, avoids errors + + [ Dustin Kirkland + swalker ] + * usr/lib/byobu/wifi_quality: avoid potential divide by zero error + -- Dustin Kirkland Sun, 23 Jan 2011 16:28:45 -0600 byobu (3.25-0ubuntu1) natty; urgency=low diff --git a/usr/bin/byobu-status b/usr/bin/byobu-status index 817ed789..c1931dc6 100755 --- a/usr/bin/byobu-status +++ b/usr/bin/byobu-status @@ -69,7 +69,10 @@ case "$P" in if which dpkg-query >/dev/null; then VER=$(set -- $(dpkg-query --show $PKG); echo "$2") fi - printf "$PKG-$VER Detailed Status Navigation\n Expand all - zr\t\tCollapse all - zm\n Expand one - zo\t\tCollapse one - zc\n\n" + printf "$PKG-$VER Detailed Status Navigation\n" + if which vim >/dev/null && `vim --version | grep -q +folding`; then + printf " Expand all - zr\t\tCollapse all - zm\n Expand one - zo\t\tCollapse one - zc\n\n" + fi for i in "$BYOBU_PREFIX/lib/$PKG"/* "$DATA/bin"/*; do i=${i##*/} [ "$i" = "menu" ] && continue diff --git a/usr/bin/byobu-status-detail b/usr/bin/byobu-status-detail index 0a1a9cf0..da468b04 100755 --- a/usr/bin/byobu-status-detail +++ b/usr/bin/byobu-status-detail @@ -17,12 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -case "$(vim --version)" in - *+folding*) +if which vim >/dev/null && `vim --version | grep -q +folding`; then exec byobu-status --detail | vim -c "set foldmethod=indent" -c "set foldminlines=0" -c "set foldnestmax=1" -c "set foldcolumn=2" -R - - ;; - *) - (which sensible-pager >/dev/null) && exec byobu-status --detail | sensible-pager - exec byobu-status --detail | less - ;; -esac +else + (which sensible-pager >/dev/null) && PAGER=sensible-pager || PAGER=less + exec byobu-status --detail | $PAGER +fi diff --git a/usr/lib/byobu/mail b/usr/lib/byobu/mail index 5a9b766d..21972809 100755 --- a/usr/lib/byobu/mail +++ b/usr/lib/byobu/mail @@ -23,7 +23,7 @@ color 2>/dev/null || color() { true; } mailfile="/var/spool/mail/$USER" if [ "$1" = "--detail" ]; then - ls -alF "$mailfile" 2>&1 + [ -s "$mailfile" ] && ls -alF "$mailfile" 2>&1 exit 0 fi diff --git a/usr/lib/byobu/reboot_required b/usr/lib/byobu/reboot_required index 2ba0bf08..46237cfb 100755 --- a/usr/lib/byobu/reboot_required +++ b/usr/lib/byobu/reboot_required @@ -26,7 +26,8 @@ reboot="/var/run/reboot-required" reload="$DIR/$PKG.reload-required" case "$1" in --detail) - ls -alF "$reboot" "$reload" 2>&1 + [ -e "$reboot" ] && ls -alF "$reboot" 2>&1 + [ -e "$reload" ] && ls -alF "$reload" 2>&1 ;; --short) [ -e "$reboot" ] && printf "Yes" || printf "No" diff --git a/usr/lib/byobu/wifi_quality b/usr/lib/byobu/wifi_quality index fa25a375..27ab41c5 100755 --- a/usr/lib/byobu/wifi_quality +++ b/usr/lib/byobu/wifi_quality @@ -27,6 +27,11 @@ fi iwconfig=`/sbin/iwconfig 2>/dev/null` bitrate=`echo "$iwconfig" | grep "Bit Rate." | sed -e "s/^.*Bit Rate.//" -e "s/ .*$//g"` -[ -z "$bitrate" ] && exit 0 -quality=`echo "$iwconfig" | grep "Link Quality." | sed -e "s/^.*Link Quality.//" -e "s/ .*$//g" | awk -F/ '{printf "%.0f", 100*$1/$2}'` +[ -z "$bitrate" ] && bitrate="0" +quality=`echo "$iwconfig" | grep "Link Quality." | sed -e "s/^.*Link Quality.//" -e "s/ .*$//g"` +if [ -z "$quality" ] || [ "$quality" = "0" ]; then + quality="0" +else + quality=`echo "$quality" | awk -F/ '{printf "%.0f", 100*$1/$2}'` +fi printf "$(color b C k)%s$(color -)$(color C k)%s,$(color -)$(color b C k)%s$(color -)$(color C k)%%$(color -) " "$bitrate" "Mbps" "$quality"