bug-gnulib
[Top][All Lists]
Advanced

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

gnupload: fix Shellcheck warnings


From: Ben Elliston
Subject: gnupload: fix Shellcheck warnings
Date: Wed, 28 Nov 2018 18:02:36 +1100
User-agent: Mutt/1.9.4 (2018-02-28)

This patch silences some warnings from Shellcheck, mostly about using
POSIX $(..) command substitutions instead of old backtick
substitutions.

Cheers, Ben

2018-11-28  Ben Elliston  <address@hidden>

        * build-aux/gnupload: Fix some Shellcheck warnings.

diff --git a/build-aux/gnupload b/build-aux/gnupload
index 37d7b6806..a2856fe6b 100755
--- a/build-aux/gnupload
+++ b/build-aux/gnupload
@@ -29,10 +29,10 @@ GPG=gpg
 # "gpg-agent is not available in this session" error
 # when gpg-agent is version 2 but gpg is still version 1.
 # FIXME-2020: remove, once all major distros ship gpg version 2 as /usr/bin/gpg
-gpg_agent_version=`(gpg-agent --version) 2>/dev/null | sed -e '2,$d' -e 
's/^[^0-9]*//'`
+gpg_agent_version=$( (gpg-agent --version) 2>/dev/null | sed -e '2,$d' -e 
's/^[^0-9]*//')
 case "$gpg_agent_version" in
   2.*)
-    gpg_version=`(gpg --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'`
+    gpg_version=$( (gpg --version) 2>/dev/null | sed -e '2,$d' -e 
's/^[^0-9]*//')
     case "$gpg_version" in
       1.*)
         if (type gpg2) >/dev/null 2>/dev/null; then
@@ -138,7 +138,7 @@ Send patches and bug reports to <address@hidden>."
 # Read local configuration file
 if test -r "$conffile"; then
   echo "$0: Reading configuration file $conffile"
-  conf=`sed 's/#.*$//;/^$/d' "$conffile" | tr "\015$nl" '  '`
+  conf=$(sed 's/#.*$//;/^$/d' "$conffile" | tr "\\015$nl" '  ')
   eval set x "$conf \"address@hidden""
   shift
 fi
@@ -186,7 +186,7 @@ while test -n "$1"; do
       collect_var=delete_symlinks
       ;;
     --symlink-regex=*)
-      symlink_expr=`expr "$1" : '[^=]*=\(.*\)'`
+      symlink_expr=$(expr "$1" : '[^=]*=\(.*\)')
       ;;
     --symlink-regex)
       symlink_expr='s|-[0-9][0-9\.]*\(-[0-9][0-9]*\)\{0,1\}\.|-latest.|'
@@ -237,7 +237,7 @@ if test -z "$to"; then
 fi
 
 if test -n "$symlink_files"; then
-  x=`echo "$symlink_files" | sed 's/[^ ]//g;s/  //g'`
+  x=$(echo "$symlink_files" | sed 's/[^ ]//g;s/  //g')
   if test -n "$x"; then
     echo "$0: Odd number of symlink arguments" >&2
     exit 1
@@ -258,7 +258,7 @@ else
       echo "$0: Cannot find '$file'" 1>&2
       exit 1
     elif test -n "$symlink_expr"; then
-      linkname=`echo $file | sed "$symlink_expr"`
+      linkname=$(echo $file | sed "$symlink_expr")
       if test -z "$linkname"; then
         echo "$0: symlink expression produces empty results" >&2
         exit 1
@@ -282,7 +282,7 @@ GNUPGHOME=${GNUPGHOME:-$HOME/.gnupg}
 # Remember this script runs with 'set -e', so if echo is not built-in
 # it will exit now.
 if $dry_run || grep -q "^use-agent" $GNUPGHOME/gpg.conf; then :; else
-  PATH=/empty echo -n "Enter GPG passphrase: "
+  PATH=/empty printf "Enter GPG passphrase: "
   stty -echo
   read -r passphrase
   stty echo
@@ -374,8 +374,8 @@ upload ()
       $dbg ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
       ;;
     download.gnu.org.ua:alpha/*|download.gnu.org.ua:ftp/*)
-      destdir_p1=`echo "$destdir" | sed 's,^[^/]*/,,'`
-      destdir_topdir=`echo "$destdir" | sed 's,/.*,,'`
+      destdir_p1=$(echo "$destdir" | sed 's,^[^/]*/,,')
+      destdir_topdir=$(echo "$destdir" | sed 's,/.*,,')
       mkdirective "$destdir_p1" "$base" "$file" "$stmt"
       echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign 
$base.directive
       for f in $files $base.directive.asc
@@ -384,7 +384,7 @@ upload ()
       done | $dbg sftp -b - puszcza.gnu.org.ua:/incoming/$destdir_topdir
       ;;
     /*)
-      dest_host=`echo "$dest" | sed 's,:.*,,'`
+      dest_host=$(echo "$dest" | sed 's,:.*,,')
       mkdirective "$destdir" "$base" "$file" "$stmt"
       echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign 
$base.directive
       $dbg cp $files $base.directive.asc $dest_host
@@ -404,7 +404,7 @@ upload ()
 stmt=
 if test -n "$symlink_files"; then
   stmt="$stmt
-`mksymlink $symlink_files`"
+$(mksymlink $symlink_files)"
 fi
 
 for file in $delete_files
@@ -422,8 +422,8 @@ done
 if test -n "$stmt"; then
   for dest in $to
   do
-    destdir=`echo $dest | sed 's/[^:]*://'`
-    upload "$dest" "$destdir" "`hostname`-$$" "" "$stmt"
+    destdir=$(echo $dest | sed 's/[^:]*://')
+    upload "$dest" "$destdir" "$(hostname)-$$" "" "$stmt"
   done
 fi
 
@@ -441,9 +441,9 @@ $replace"
     fi
     #
     files="$file $file.sig"
-    destdir=`echo $dest | sed 's/[^:]*://'`
+    destdir=$(echo $dest | sed 's/[^:]*://')
     if test -n "$symlink_expr"; then
-      linkname=`echo $file | sed "$symlink_expr"`
+      linkname=$(echo $file | sed "$symlink_expr")
       stmt="$stmt
 symlink: $file $linkname
 symlink: $file.sig $linkname.sig"

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]