Add support for "dry run" mode
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 21 Oct 2006 20:34:37 +0000 (20:34 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 21 Oct 2006 20:34:37 +0000 (20:34 +0000)
cp-po

diff --git a/cp-po b/cp-po
index 77be3508a98e5f456ef5a808908a6319d9cf6766..0957a9c606608773828ffb8b3c7ac2c144a625ab 100755 (executable)
--- a/cp-po
+++ b/cp-po
@@ -3,7 +3,7 @@
 # Copies PO files from a PgFoundry repository structure to a PostgreSQL
 # source tree.
 #
-# Usage: cp-po SOURCEDIR DESTDIR
+# Usage: cp-po [-n] SOURCEDIR DESTDIR
 #
 # Written by Peter Eisentraut
 # Public domain
@@ -12,6 +12,16 @@ set -e
 
 me=$(basename $0)
 
+TEMP=$(getopt n "$@")
+eval set -- "$TEMP"
+
+while true; do
+       case $1 in
+               -n)     run=: ; shift;;
+               --)     shift; break;;
+       esac
+done
+
 srcdir=$1
 if [ -z "$srcdir" ]; then
        echo "$me: no source directory specified" 1>&2
@@ -41,7 +51,7 @@ for srcfile in $(find "$srcdir" -name '*.po'); do
                        targetdir=$(echo $y | sed 's,nls\.mk$,po,')
                        if ! diff -I '\$\(Header\|Id\|PostgreSQL\):.*\$' $srcfile $targetdir/$lang.po >/dev/null; then
                                echo " cp $srcfile $targetdir/$lang.po"
-                               cp $srcfile $targetdir/$lang.po
+                               $run cp $srcfile $targetdir/$lang.po
                        fi
                fi
        done