summaryrefslogtreecommitdiff
path: root/contrib/rpshowall.sh
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2012-12-17 10:03:39 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-01-20 19:19:00 +0100
commit09a464eb213212ac6538bc4bba9d2e391562b100 (patch)
tree8c14b0144bd54f21d34af3613bd13e365a2a293e /contrib/rpshowall.sh
parent70ae853c054dd2b1b6cbf2fcffb678331ae3a031 (diff)
downloadratpoison-09a464eb213212ac6538bc4bba9d2e391562b100.zip
basic contrib/ cleanup
* (*.pl, rpws) don't hardcode path to Perl but rely on /usr/bin/env * (allwindows.sh) don't require bash * (rpshowall.sh) properly handle arguments, use portable shell arithmetic * (*.sh) use more quotes * (*.pl, split.sh) use 'ratpoison' if RATPOISON isn't in the environment (and don't error out)
Diffstat (limited to 'contrib/rpshowall.sh')
-rw-r--r--contrib/rpshowall.sh33
1 files changed, 19 insertions, 14 deletions
diff --git a/contrib/rpshowall.sh b/contrib/rpshowall.sh
index cd69ce3..458f2fa 100644
--- a/contrib/rpshowall.sh
+++ b/contrib/rpshowall.sh
@@ -17,18 +17,23 @@
# rpshowall 0
# show all open windows, do not restore previous frame layout
-if [ -z $RATPOISON ]; then
+if [ -z "$RATPOISON" ]; then
RATPOISON=ratpoison
fi
# Parse input argument
-if [ $*>0 ]; then
- wait="$*"
-else
- wait=-1
-fi
-
+case $# in
+ 0) wait=-1
+ ;;
+ 1)
+ wait=$1
+ ;;
+ *)
+ printf '%s\n' "Usage: $0 [sleep_seconds]" >&2
+ exit 1
+ ;;
+esac
# Save current frameset
@@ -40,16 +45,16 @@ curlayout=`$RATPOISON -c fdump`
# Create split view of all open windows
$RATPOISON -c only
-i=2;
-while [ $i -le $framecount ]; do
- if [ $i -le `echo $framecount/2 | bc` ] ; then
+i=2
+while [ "$i" -le "$framecount" ]; do
+ if [ "$i" -le $(($framecount/2)) ] ; then
$RATPOISON -c vsplit
else
$RATPOISON -c hsplit
fi
$RATPOISON -c focus
$RATPOISON -c focus
- i=$[$i+1];
+ i=$(($i+1));
done
# Depending on the argument the script was executed with,
@@ -63,11 +68,11 @@ if [ $wait -eq 0 ]; then
$RATPOISON -c only
else
$RATPOISON -i -c windows
- if [ $wait -eq -1 ]; then
- echo -n "Hit return to restore window layout. "
+ if [ "$wait" -eq -1 ]; then
+ printf '%s' "Hit return to restore window layout. "
read i
else
- sleep $wait
+ sleep "$wait"
fi
$RATPOISON -c "frestore $curlayout"
fi