summaryrefslogtreecommitdiff
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
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)
-rwxr-xr-xcontrib/allwindows.sh8
-rw-r--r--contrib/clickframe.pl5
-rw-r--r--contrib/expose.pl4
-rwxr-xr-xcontrib/genrpbindings4
-rw-r--r--contrib/rpbatch.pl4
-rw-r--r--contrib/rpshowall.sh33
-rwxr-xr-xcontrib/rpws3
-rwxr-xr-xcontrib/split.sh4
8 files changed, 37 insertions, 28 deletions
diff --git a/contrib/allwindows.sh b/contrib/allwindows.sh
index 995f367..a1c291b 100755
--- a/contrib/allwindows.sh
+++ b/contrib/allwindows.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Copyright (C) 2003 Rupert Levene
# Author: Rupert Levene <r.levene@lancaster.ac.uk>
@@ -12,15 +12,15 @@ IFS='
list=''
# Allow external scripts to tell it where ratpoison is
-if [ -z $RATPOISON ]; then
+if [ -z "$RATPOISON" ]; then
RATPOISON=ratpoison
fi
GROUPLIST=$($RATPOISON -c groups)
SED_GET_NUM='s/^\([0-9]*\).*/\1/'
-FIRSTGROUPNUM=$(echo "$GROUPLIST"|head -1|sed -e "$SED_GET_NUM")
-LASTGROUP=$(echo "$GROUPLIST"|tail -1)
+FIRSTGROUPNUM=$(echo "$GROUPLIST"|head -n 1|sed -e "$SED_GET_NUM")
+LASTGROUP=$(echo "$GROUPLIST"|tail -n 1)
CURRENTGROUPNUM=$(echo "$GROUPLIST"|grep '^[0-9]*\*'|sed -e "$SED_GET_NUM")
$RATPOISON -c "gselect $FIRSTGROUPNUM"
diff --git a/contrib/clickframe.pl b/contrib/clickframe.pl
index e4836b9..4268074 100644
--- a/contrib/clickframe.pl
+++ b/contrib/clickframe.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
#
# Copyright (C) 2003,2004 Shawn Betts
#
@@ -19,10 +19,9 @@
# Make sure the env vars are there
$ENV{XBINDKEYS_BUTTONLOC} || die '$XBINDKEYS_BUTTONLOC not bound';
-$ENV{RATPOISON} || die '$RATPOISON not bound';
# Parse the required environment variables
-$ratpoison_bin = $ENV{RATPOISON};
+$ratpoison_bin = $ENV{RATPOISON} || 'ratpoison';
($x_loc,$y_loc) = split(/,/, $ENV{XBINDKEYS_BUTTONLOC});
# Rip the frameset from ratpoison
diff --git a/contrib/expose.pl b/contrib/expose.pl
index 7f0600b..0a7127e 100644
--- a/contrib/expose.pl
+++ b/contrib/expose.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
# Maintainer: Trent Buck <[EMAIL PROTECTED]>
# License: Public Domain
@@ -24,7 +24,7 @@ require "assert.pl"; #used for validation.
use strict;
my $N_LIMIT = 2;
my $LIMIT = 0.01; #smaller number --> slower, but more accurate
-my $RATPOISON = 'ratpoison';
+my $RATPOISON = $ENV{RATPOISON} || 'ratpoison';
#-- main -----------------------------------------------------------------------
diff --git a/contrib/genrpbindings b/contrib/genrpbindings
index 62efa6d..0f924d3 100755
--- a/contrib/genrpbindings
+++ b/contrib/genrpbindings
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
# genrpbindings -- generate ratpoison bindings for various languages
#
# Copyright (C) 2003, 2004 Ryan Yeske, Doug Kearns, Shawn Betts
@@ -36,6 +36,8 @@
# import ratpoison
# ratpoison.echo( "hello world" )
+use warnings;
+
$\="\n";
# set this to your rp binary
diff --git a/contrib/rpbatch.pl b/contrib/rpbatch.pl
index 6fce57f..0f1c50e 100644
--- a/contrib/rpbatch.pl
+++ b/contrib/rpbatch.pl
@@ -1,9 +1,9 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
#
# Copyright (C) 2003 Shawn Betts
# Execute a sequence of commands read from stdin.
-$ratpoison = $ENV{RATPOISON} or die "Where is ratpoison?";
+$ratpoison = $ENV{RATPOISON} || 'ratpoison';
while (<>) {
chomp;
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
diff --git a/contrib/rpws b/contrib/rpws
index 2e1a3bb..49105c5 100755
--- a/contrib/rpws
+++ b/contrib/rpws
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
#
# Copyright (c) 2009 Hatem Nassrat <hnassrat@gmail.com>
@@ -21,6 +21,7 @@
#
use strict;
+use warnings;
use Fcntl qw (:flock);
use Getopt::Std;
diff --git a/contrib/split.sh b/contrib/split.sh
index 16617cf..1c8c009 100755
--- a/contrib/split.sh
+++ b/contrib/split.sh
@@ -8,7 +8,9 @@
# Split the current frame into 16 little frames. This is an example of
# how to script ratpoison.
-RATPOISON=ratpoison
+if [ -z "$RATPOISON" ]; then
+ RATPOISON=ratpoison
+fi
# $RATPOISON -c only