From 3054022d2d402041b6a3d2052b47238e2b830f89 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 10 Mar 2010 18:40:54 -0600 Subject: [PATCH] bin/byobu-export, bin/byobu-reconnect-sockets, bin/byobu-status, lib/byobu/cpu_temp: avoid programmatic use of ls in for loops, LP: #452405 --- debian/changelog | 3 +++ usr/bin/byobu-export | 5 ++++- usr/bin/byobu-reconnect-sockets | 4 +++- usr/bin/byobu-status | 3 ++- usr/lib/byobu/cpu_temp | 7 ++++--- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index a9accdad..1e536b9a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,9 @@ byobu (2.63) unreleased; urgency=low use /var/run/screen as the socket directory, LP: #535378 * usr/bin/byobu-config: change a sample reference from "bash" to "shell" again for portability, LP: #535407 + * bin/byobu-export, bin/byobu-reconnect-sockets, bin/byobu-status, + lib/byobu/cpu_temp: avoid programmatic use of ls in for loops, + LP: #452405 [ Torsten Spindler ] * debian/postinst: handle situation where /var/run/screen does not diff --git a/usr/bin/byobu-export b/usr/bin/byobu-export index 8e86983e..54512e3f 100755 --- a/usr/bin/byobu-export +++ b/usr/bin/byobu-export @@ -94,7 +94,10 @@ ln -sf usr/share/$PKG/profiles/common "$DIR/.$PKG/profile" ln -sf usr/share/$PKG/ec2/rates.us_ca "$DIR/.$PKG/ec2_rates" # Some gardening; update paths to be $HOME-based -for i in $(ls /usr/bin/$PKG-* | grep -v "install"); do +for i in /usr/bin/$PKG-*; do + if echo "$i" | grep -qs "install"; then + continue + fi bin=$(basename "$i") sed -i "s:$bin:\$HOME/.$PKG$i:g" $(find $DIR -type f) done diff --git a/usr/bin/byobu-reconnect-sockets b/usr/bin/byobu-reconnect-sockets index 2647c6b2..b79a0e94 100755 --- a/usr/bin/byobu-reconnect-sockets +++ b/usr/bin/byobu-reconnect-sockets @@ -31,12 +31,14 @@ if ! echo $- | grep -qs i; then fi # Establish gpg-agent socket, helps when reconnecting to a detached session -for i in $(ls "$HOME/.gnupg/"gpg-agent-info-*); do +# Sorry, ls -t is needed here, to sort by time +for i in $(ls -t "$HOME/.gnupg/"gpg-agent-info-*); do . "$i" || continue export GPG_AGENT_INFO && break done # Reconnect dbus, source the most recently touched session-bus +# Sorry, ls -t is needed here, to sort by time for i in $(ls -t "$HOME/.dbus/session-bus/" 2>/dev/null); do . "$HOME/.dbus/session-bus/$i" || continue export DBUS_SESSION_BUS_ADDRESS && break diff --git a/usr/bin/byobu-status b/usr/bin/byobu-status index d518950a..5a349be6 100755 --- a/usr/bin/byobu-status +++ b/usr/bin/byobu-status @@ -67,7 +67,8 @@ case "$P" in VER=`dpkg-query --show $PKG | awk '{print "-" $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" - for i in $(ls "/usr/lib/$PKG" "$HOME/.$PKG/bin" 2>/dev/null | grep -v "^/" | sort -u); do + for i in "/usr/lib/$PKG"/* "$HOME/.$PKG/bin"/*; do + i=$(echo "$i" | sed "s:^.*/::") [ "$i" = "menu" ] && continue script=`find_script $i` short=`$script --short | sed 's/^\s*//' | sed 's/\s*$//' | sed 's/.{[^}]*}//g'` || true diff --git a/usr/lib/byobu/cpu_temp b/usr/lib/byobu/cpu_temp index f0dda885..b50eb790 100755 --- a/usr/lib/byobu/cpu_temp +++ b/usr/lib/byobu/cpu_temp @@ -22,10 +22,11 @@ PKG="byobu" color 2>/dev/null || color() { true; } DIR="/proc/acpi/thermal_zone" -if [ "$1" = "--detail" ]; then - for i in `ls $DIR 2>/dev/null`; do +if [ "$1" = "--detail" ] && [ -d "$DIR" ]; then + for i in "$DIR"/*; do + [ -r "$i" ] || continue echo "$i:" - cat "$DIR/$i"/* + cat "$i"/* done exit 0 fi