[PATCH] basic contrib/ cleanup

[email protected] (Jérémie Courrèges -Anglas)
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
Patch attached below.

-- 
Jérémie Courrèges-Anglas
GPG Fingerprint: 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494

_______________________________________________
Ratpoison-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ratpoison-devel
0001-basic-contrib-cleanup.patch (text/x-patch, 6.2 KB)
From 62c5725d1a2e2ff76c69a3629979d08cc6802806 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= <[email protected]>
Date: Mon, 17 Dec 2012 10:03:39 +0100
Subject: [PATCH] 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)
---
 contrib/allwindows.sh |  8 ++++----
 contrib/clickframe.pl |  5 ++---
 contrib/expose.pl     |  4 ++--
 contrib/genrpbindings |  4 +++-
 contrib/rpbatch.pl    |  4 ++--
 contrib/rpshowall.sh  | 33 +++++++++++++++++++--------------
 contrib/rpws          |  3 ++-
 contrib/split.sh      |  4 +++-
 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 <[email protected]>
 
@@ -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 <[email protected]>
@@ -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
 
-- 
1.8.0.1
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (OpenBSD)

iQIcBAEBCgAGBQJQzud8AAoJEGGRj78GoRSUMpIQAKB9G3ku1SYoswnbd6ITUKAY
ZUqha78CMXYJckxawnysS/k3NS+pLc3aTZwnTq+XLbD/1GixRBcOrovlk21znHOY
iGFGvSgqdWaWPahNGy0TNfBISVk4dzTiNCO8i2kJvGXwYXY9TTdBW4sn0gfW/Vg+
EJX3WmtLK+mjUnbZQs0WSR++M+H0QkdBVjlittvMN3CENk1baqUXKWd+64f7gKc2
D3sbCa/b4HQFs0w22w+GxvrG5qADJdBwPTvuPoGUwVrWJ3/hGQSeVqTpXapysWVK
4vK6llmbHeIcAQ/4IYXB6Nsp7TuMPFBqsAh3J04AS3/NGJ2Nk0Af4v8JhwDGAXCx
rqScJPKiIuxk+Ju2AvucBz65wX5rAcwxSbnO/fgQS3Zwuka6Rj3EHVq8b8YWj56R
g7zmvIbGaHTPSlxx3a+hZHzRZQAB+v341K3j7Jbq43Gj7Jb5ZZ654+UnLpuSs6A2
gNsaJ257KEyFl/6odc6XNhQf2fU5Hzp97UgVUsWhxwy/Ys/wYqN33yoj5FS3j6NT
MiexBXSTc1syO9mMRH1Ccmw7YaS8zWSYnpCrgapEuOvlLN/EhejR7sAS/PtXBHRL
R1q7jxoNSkz67WSskZHJpPpiRnhx/u5Zoi4eh0s2L1GnhYKIaKKSVck43bxIBfLu
wQlruCaSmkosOVnyDWU/
=Z82t
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.