[PATCH v2 2/8] Do not use shell's old-style command substitution

Rene Kita <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <[email protected]>
To quote the BashFAQ[0]:
Why is $(...) preferred over `...` (backticks)?

The `cmd` backtick format is the legacy syntax for command substitution,
required only by more than 30-year-old Bourne shells. ...

[0]: http://mywiki.wooledge.org/BashFAQ/082
---
 check_sec.sh          |  4 ++--
 contrib/iconv/make.sh |  2 +-
 mkchangelog.sh        |  2 +-
 mkreldate.sh          |  4 ++--
 version.sh            | 10 +++++-----
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/check_sec.sh b/check_sec.sh
index 179ac1ff..03bf2188 100755
--- a/check_sec.sh
+++ b/check_sec.sh
@@ -4,7 +4,7 @@
 # grep for some things which may look like security problems.
 #
 
-TMPFILE=`mktemp check_sec.tmp.XXXXXX` || exit 1
+TMPFILE=$(mktemp check_sec.tmp.XXXXXX) || exit 1
 
 RV=0;
 
@@ -27,7 +27,7 @@ do_check_files ()
 
 do_check ()
 {
-        do_check_files "$1" "$2" "$3" `find . -name '*.c' -print`
+        do_check_files "$1" "$2" "$3" $(find . -name '*.c' -print)
 }
 
 do_check '\<fopen.*'\"'.*w' __FOPEN_CHECKED__ "Alert: Unchecked fopen calls."
diff --git a/contrib/iconv/make.sh b/contrib/iconv/make.sh
index 1db621e6..1382b151 100755
--- a/contrib/iconv/make.sh
+++ b/contrib/iconv/make.sh
@@ -21,6 +21,6 @@ for f in $LIBICONV/libcharset/tools/* ; do
 		sed '1,/^$/d' $f | awk '($4 != $3) { printf ("iconv-hook %s %s\n", $4, $3); }' | \
 			sed -e 's/^iconv-hook SJIS /iconv-hook Shift_JIS /gi' |
 			sort -u > tmp.rc )
-	test -s tmp.rc && mv tmp.rc iconv.`basename $f`.rc
+	test -s tmp.rc && mv tmp.rc iconv.$(basename $f).rc
 	rm -f tmp.rc
 done
diff --git a/mkchangelog.sh b/mkchangelog.sh
index 8a257023..9f551012 100755
--- a/mkchangelog.sh
+++ b/mkchangelog.sh
@@ -5,7 +5,7 @@
 # This would generate based on the last update of the ChangeLog, instead:
 # lrev=$(git log -1 --pretty=format:"%H" ChangeLog)
 
-lrev=`git describe --tags --match 'mutt-*-rel' --abbrev=0`
+lrev=$(git describe --tags --match 'mutt-*-rel' --abbrev=0)
 
 # This is a rough approximation of the official ChangeLog format
 # previously generated by hg.  Git doesn't provide enough formatting
diff --git a/mkreldate.sh b/mkreldate.sh
index 927967d5..b9be6373 100755
--- a/mkreldate.sh
+++ b/mkreldate.sh
@@ -3,9 +3,9 @@
 # Generates the reldate.h contents from either git or the ChangeLog file
 
 if [ -r ".git" ] && command -v git >/dev/null 2>&1; then
-  reldate=`TZ=UTC git log -1 --date=format-local:"%F" --pretty=format:"%cd"`
+  reldate=$(TZ=UTC git log -1 --date=format-local:"%F" --pretty=format:"%cd")
 else
-  reldate=`head -n 1 ChangeLog | LC_ALL=C cut -d ' ' -f 1`
+  reldate=$(head -n 1 ChangeLog | LC_ALL=C cut -d ' ' -f 1)
 fi
 
 echo $reldate
diff --git a/version.sh b/version.sh
index 6d87b31f..6abdcc0c 100644
--- a/version.sh
+++ b/version.sh
@@ -3,17 +3,17 @@
 # Switch to directory where this script lives so that further commands are run
 # from the root directory of the source.  The script path and srcdir are double
 # quoted to allow the space character to appear in the path.
-srcdir=`dirname "$0"` && cd "$srcdir" || exit 1
+srcdir=$(dirname "$0") && cd "$srcdir" || exit 1
 
 # Ensure that we have a repo here.
 # If not, just cat the VERSION file; it contains the latest release number.
 { [ -r ".git" ] && command -v git >/dev/null 2>&1; } \
 || exec cat VERSION
 
-latesttag=`git describe --tags --match 'mutt-*-rel' --abbrev=0`
-version=`echo $latesttag | sed -e s/mutt-// -e s/-rel// -e s/-/./g`
-distance=`git rev-list --count $latesttag..`
-commitid=`git rev-parse --short HEAD`
+latesttag=$(git describe --tags --match 'mutt-*-rel' --abbrev=0)
+version=$(echo "$latesttag" | sed -e s/mutt-// -e s/-rel// -e s/-/./g)
+distance=$(git rev-list --count "$latesttag"..)
+commitid=$(git rev-parse --short HEAD)
 
 [ x = "x$distance" ] && exec cat VERSION
 
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.