Package: devscripts
Version: 2.11.3
Severity: wishlist

The following patch updates to use POSIX[1] command substitution $() in
place of backtics (``).

Motivation:

- Recommended practise. The $() is recommend by many[2]. It nests easily.
- Readability. In high resolution display a "tick" is hard to see.
  Different font may also make reading the "tick" difficult to distinguish.
- Typing convenience. The backtick key may be placed in difficult
  position in non-US keyboard. E.g acrobatics is needed with FI-keyboard
  by pressing three keys in succession: AltGr + key + Space char

REFERENCES

[1]
POSIX standard IEEE Std 1003.1: 2.6.3 Command Substitution
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03

[2]
Bash manual
    "...old-style backquote" in section "3.5.4 Command Substitution"
    http://www.gnu.org/software/bash/manual/bashref.html#Command-Substitution

BashFAQ:
    "$(...) preferred over `...` (backticks)?"

Advanced Bash-Scripting Guide:
    "...The $(...) form has superseded backticks for command substitution."
    http://tldp.org/LDP/abs/html/commandsub.html

Bash Hackers Wiki:
    "[conclusion]... it's clean syntax, intuitive, more readable,
    nestable, its inner parsing is separate"
    http://wiki.bash-hackers.org/syntax/expansion/cmdsubst

-- Package-specific info:

--- /etc/devscripts.conf ---

--- ~/.devscripts ---
Not present

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages devscripts depends on:
ii  dpkg-dev   1.16.1.2
ii  libc6      2.13-26
ii  perl       5.14.2-7
ii  python     2.7.2-10
ii  python2.6  2.6.7-4
ii  python2.7  2.7.2-13
>From 49971a68e7576d89d538815addf776b9273adf15 Mon Sep 17 00:00:00 2001
From: Jari Aalto <[email protected]>
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 <[email protected]>
---
 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

Reply via email to