[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

X Strike Force XFree86 SVN commit: r1122 - in trunk/debian: . scripts



Author: branden
Date: 2004-03-02 12:53:08 -0500 (Tue, 02 Mar 2004)
New Revision: 1122

Added:
   trunk/debian/scripts/validate-posix-sh
Modified:
   trunk/debian/changelog
Log:
Add script to help package maintainers validate shell scripts against
POSIX-compatible shell interpreters.


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2004-03-02 07:13:18 UTC (rev 1121)
+++ trunk/debian/changelog	2004-03-02 17:53:08 UTC (rev 1122)
@@ -22,8 +22,12 @@
   * Invoke printf with only one format string argument.
     - debian/xserver-xfree86.bug
 
- -- Branden Robinson <branden@debian.org>  Tue,  2 Mar 2004 02:12:35 -0500
+  * Add script to help package maintainers validate shell scripts against
+    POSIX-compatible shell interpreters.
+    - debian/scripts/validate-posix-sh
 
+ -- Branden Robinson <branden@debian.org>  Tue,  2 Mar 2004 12:51:46 -0500
+
 xfree86 (4.3.0-3) unstable; urgency=medium
 
   * Urgency due to fix for serious bug which frustrates removal of library

Added: trunk/debian/scripts/validate-posix-sh
===================================================================
--- trunk/debian/scripts/validate-posix-sh	2004-03-02 07:13:18 UTC (rev 1121)
+++ trunk/debian/scripts/validate-posix-sh	2004-03-02 17:53:08 UTC (rev 1122)
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# $Id$
+
+# Run this before committing changes to shell scripts.
+
+PROGNAME=${0##*/}
+
+ASH="ash -n"
+BASH="bash --posix -n"
+DASH="dash -n"
+KSH="ksh -n"
+
+usage () {
+    cat <<EOF
+Usage: $PROGNAME SCRIPT ...
+Perform syntax checks on each SCRIPT with POSIX-compatible shells available on
+the system.
+EOF
+}
+
+howl () {
+    echo "$PROGNAME: error; $*" >&2
+}
+
+warn () {
+    echo "$PROGNAME: warning; $*" >&2
+}
+
+if [ -z "$1" ]; then
+    usage >&2
+    exit 2
+fi
+
+while [ -n "$1" ]; do
+    if [ ! -r "$1" ]; then
+        howl "\"$1\" does not exist or is not readable"
+        usage >&2
+        exit 2
+    fi
+    for SH in "$ASH" "$BASH" "$DASH" "$KSH"; do
+        CMD=${SH%% *}
+        if which "$CMD" >/dev/null 2>&1; then
+            if ! $SH $1; then
+                echo "$PROGNAME: \"$1\" failed syntax check with $CMD"
+            fi
+        else
+            warn "cannot verify correctness with $CMD; shell not available"
+        fi
+    done
+    shift
+done
+
+# vim:set ai et sts=4 sw=4 tw=80:


Property changes on: trunk/debian/scripts/validate-posix-sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id



Reply to: