>From 49971a68e7576d89d538815addf776b9273adf15 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Wed, 8 Feb 2012 00:32:29 -0500
Subject: [PATCH] debsign.sh: Use POSIX command substitution $()
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit


Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
 scripts/debsign.sh |   65 ++++++++++++++++++++++++++++------------------------
 1 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/scripts/debsign.sh b/scripts/debsign.sh
index 3751ca9..ce71a13 100755
--- a/scripts/debsign.sh
+++ b/scripts/debsign.sh
@@ -25,7 +25,7 @@
 set -e
 
 PRECIOUS_FILES=0
-PROGNAME=`basename $0`
+PROGNAME=$(basename $0)
 MODIFIED_CONF_MSG='Default settings modified by devscripts configuration files:'
 
 # Temporary directories
@@ -103,7 +103,7 @@ temp_filename() {
     local filename
 
     if ! [ -w "$(dirname "$1")" ]; then
-	filename=`mktemp -t "$(basename "$1").$2.XXXXXXXXXX"` || {
+	filename=$(mktemp -t "$(basename "$1").$2.XXXXXXXXXX") || {
 	    echo "$PROGNAME: Unable to create temporary file; aborting" >&2
 	    exit 1
 	}
@@ -162,9 +162,9 @@ signfile () {
     ASCII_SIGNED_FILE="${UNSIGNED_FILE}.asc"
     (cat "$1" ; echo "") > "$UNSIGNED_FILE"
 
-    gpgversion=`$signcommand --version | head -n 1 | cut -d' ' -f3`
-    gpgmajorversion=`echo $gpgversion | cut -d. -f1`
-    gpgminorversion=`echo $gpgversion | cut -d. -f2`
+    gpgversion=$($signcommand --version | head -n 1 | cut -d' ' -f3)
+    gpgmajorversion=$(echo $gpgversion | cut -d. -f1)
+    gpgminorversion=$(echo $gpgversion | cut -d. -f2)
 
     if [ $gpgmajorversion -gt 1 -o $gpgminorversion -ge 4 ]
     then
@@ -205,7 +205,7 @@ withecho () {
 # and failure if the file needs signing.  Parameters: $1=filename,
 # $2=file description for message (dsc or changes)
 check_already_signed () {
-    [ "`head -n 1 \"$1\"`" = "-----BEGIN PGP SIGNED MESSAGE-----" ] || \
+    [ "$(head -n 1 \"$1\")" = "-----BEGIN PGP SIGNED MESSAGE-----" ] || \
 	return 1
 
     local resign
@@ -276,7 +276,7 @@ else
 
     # We do not replace this with a default directory to avoid accidentally
     # signing a broken package
-    DEBRELEASE_DEBS_DIR="`echo \"$DEBRELEASE_DEBS_DIR\" | sed -e 's%/\+%/%g; s%\(.\)/$%\1%;'`"
+    DEBRELEASE_DEBS_DIR="$(echo \"$DEBRELEASE_DEBS_DIR\" | sed -e 's%/\+%/%g; s%\(.\)/$%\1%;')"
     if ! [ -d "$DEBRELEASE_DEBS_DIR" ]; then
 	debsdir_warning="config file specified DEBRELEASE_DEBS_DIR directory $DEBRELEASE_DEBS_DIR does not exist!"
     fi
@@ -382,10 +382,10 @@ dosigning() {
 	remotechanges=$changes
 	remotedsc=$dsc
 	remotecommands=$commands
-	remotedir="`perl -e 'chomp($_="'"$dsc"'"); m%/% && s%/[^/]*$%% && print'`"
-	changes=`basename "$changes"`
-	dsc=`basename "$dsc"`
-	commands=`basename "$commands"`
+	remotedir="$(perl -e 'chomp($_="'"$dsc"'"); m%/% && s%/[^/]*$%% && print')"
+	changes=$(basename "$changes")
+	dsc=$(basename "$dsc")
+	commands=$(basename "$commands")
 
 	if [ -n "$changes" ]
 	then
@@ -403,8 +403,8 @@ dosigning() {
 	    for changes in $changes
 	    do
 		printf "\n"
-		dsc=`echo "${remotedir+$remotedir/}$changes" | \
-		    perl -pe 's/\.changes$/.dsc/; s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/'`
+		dsc=$(echo "${remotedir+$remotedir/}$changes" |
+		      perl -pe 's/\.changes$/.dsc/; s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/')
 		dosigning;
 	    done
 	    exit 0;
@@ -423,19 +423,24 @@ dosigning() {
 	   echo "Leaving current signature unchanged." >&2
 	   return
 	}
+
 	if [ -n "$maint" ]
-	then maintainer="$maint"
-	# Try the "Changed-By:" field first
-	else maintainer=`sed -n 's/^Changed-By: //p' $changes`
+	then
+	    maintainer="$maint"
+	else
+	    # Try the "Changed-By:" field first
+	    maintainer=$(sed -n 's/^Changed-By: //p' $changes)
 	fi
+
 	if [ -z "$maintainer" ]
-	then maintainer=`sed -n 's/^Maintainer: //p' $changes`
+	then
+	    maintainer=$(sed -n 's/^Maintainer: //p' $changes)
 	fi
 
 	signas="${signkey:-$maintainer}"
 
 	# Is there a dsc file listed in the changes file?
-	if grep -q `basename "$dsc"` "$changes"
+	if grep -q $(basename "$dsc") "$changes"
 	then
 	    if [ -n "$remotehost" ]
 	    then
@@ -448,9 +453,9 @@ dosigning() {
 		exit 1
 	    fi
 	    check_already_signed "$dsc" "dsc" || withecho signfile "$dsc" "$signas"
-	    dsc_md5=`md5sum $dsc | cut -d' ' -f1`
-	    dsc_sha1=`sha1sum $dsc | cut -d' ' -f1`
-	    dsc_sha256=`sha256sum $dsc | cut -d' ' -f1`
+	    dsc_md5=$(md5sum $dsc | cut -d' ' -f1)
+	    dsc_sha1=$(sha1sum $dsc | cut -d' ' -f1)
+	    dsc_sha256=$(sha256sum $dsc | cut -d' ' -f1)
 
 	    temp_changes="$(temp_filename "$changes" "temp")"
 	    cp "$changes" "$temp_changes"
@@ -569,7 +574,7 @@ for valid format" >&2;
 	if [ -n "$maint" ]
 	then maintainer="$maint"
 	else
-            maintainer=`sed -n 's/^Uploader: //p' $commands`
+            maintainer=$(sed -n 's/^Uploader: //p' $commands)
             if [ -z "$maintainer" ]
             then
 		echo "Unable to parse Uploader, .commands file invalid."
@@ -602,10 +607,10 @@ for valid format" >&2;
 	if [ -n "$maint" ]
 	then maintainer="$maint"
 	# Try the new "Changed-By:" field first
-	else maintainer=`sed -n 's/^Changed-By: //p' $dsc`
+	else maintainer=$(sed -n 's/^Changed-By: //p' $dsc)
 	fi
 	if [ -z "$maint" ]
-	then maintainer=`sed -n 's/^Maintainer: //p' $dsc`
+	then maintainer=$(sed -n 's/^Maintainer: //p' $dsc)
 	 fi
 
 	signas="${signkey:-$maintainer}"
@@ -636,19 +641,19 @@ case $# in
 	    exit 1
 	fi
 
-	mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
+	mustsetvar package "$(dpkg-parsechangelog | sed -n 's/^Source: //p')" \
 	    "source package"
-	mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
+	mustsetvar version "$(dpkg-parsechangelog | sed -n 's/^Version: //p')" \
 	    "source version"
 
 	if [ "x$sourceonly" = x ]
 	then
-	    mustsetvar arch "`dpkg-architecture -a${targetarch} -t${targetgnusystem} -qDEB_HOST_ARCH`" "build architecture"
+	    mustsetvar arch "$(dpkg-architecture -a${targetarch} -t${targetgnusystem} -qDEB_HOST_ARCH)" "build architecture"
 	else
 	    arch=source
 	fi
 
-	sversion=`echo "$version" | perl -pe 's/^\d+://'`
+	sversion=$(echo "$version" | perl -pe 's/^\d+://')
 	pv="${package}_${sversion}"
 	pva="${package}_${sversion}_${arch}"
 	dsc="$debsdir/$pv.dsc"
@@ -682,8 +687,8 @@ case $# in
 		    ;;
 	        *.changes)
 		    changes=$1
-		    dsc=`echo $changes | \
-			perl -pe 's/\.changes$/.dsc/; s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/'`
+		    dsc=$(echo $changes |
+			  perl -pe 's/\.changes$/.dsc/; s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/')
 		    commands=
 		    ;;
 		*.commands)
-- 
1.7.9

