[Skiboot] [PATCH] Use $() rather than backticks in all shell

Stewart Smith stewart at linux.ibm.com
Mon Sep 10 14:20:03 AEST 2018


The cool kids are all using $() these days as backticks are all
backwards and uncool.

Practically speaking, it makes it easier to escape things, nest things,
and all the other reasons listed on http://mywiki.wooledge.org/BashFAQ/082

Signed-off-by: Stewart Smith <stewart at linux.ibm.com>
---
 libstb/sign-with-local-keys.sh                     |  2 +-
 make_offsets.sh                                    |  2 +-
 make_version.sh                                    | 12 ++++++------
 opal-ci/build-centos7.sh                           |  8 ++++----
 opal-ci/build-fedora27.sh                          |  4 ++--
 opal-ci/build-qemu-powernv.sh                      |  2 +-
 opal-ci/build-ubuntu-16.04.sh                      |  6 +++---
 opal-ci/build-ubuntu-18.04.sh                      |  4 ++--
 test/hello_world/run_mambo_hello_world.sh          |  8 ++++----
 test/hello_world/run_mambo_p9_hello_world.sh       |  8 ++++----
 test/hello_world/run_qemu_hello_world.sh           |  6 +++---
 test/make-boot-coverage-report.sh                  |  2 +-
 test/run_mambo_boot_test.sh                        |  6 +++---
 test/run_qemu-jessie-debian-installer_boot_test.sh |  8 ++++----
 test/run_qemu_boot_test.sh                         |  8 ++++----
 test/sreset_world/run_mambo_p9_sreset.sh           |  8 ++++----
 test/sreset_world/run_mambo_sreset.sh              |  8 ++++----
 17 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/libstb/sign-with-local-keys.sh b/libstb/sign-with-local-keys.sh
index efddabffef8d..b78a079bfefe 100755
--- a/libstb/sign-with-local-keys.sh
+++ b/libstb/sign-with-local-keys.sh
@@ -11,7 +11,7 @@ fi
 KEYLOC=$3
 LABEL=$4
 
-T=`mktemp -d`
+T=$(mktemp -d)
 LABEL_ARG=""
 if [ ! -z "$LABEL" ]; then
 	LABEL_ARG="-L $LABEL"
diff --git a/make_offsets.sh b/make_offsets.sh
index 34ba5f667b18..0c480be035f1 100755
--- a/make_offsets.sh
+++ b/make_offsets.sh
@@ -5,6 +5,6 @@ cat <<EOF
 #define ASM_OFFSETS_H
 /* Derived from $1 by make_offsets.sh */
 
-`grep '#define' $1`
+$(grep '#define' $1)
 #endif /* ASM_OFFSETS_H */
 EOF
diff --git a/make_version.sh b/make_version.sh
index c757e914bfe0..59fe01c728ab 100755
--- a/make_version.sh
+++ b/make_version.sh
@@ -14,14 +14,14 @@ fi
 
 if test -e .git || git rev-parse --is-inside-work-tree > /dev/null 2>&1;
 then
-	version=`git describe --exact-match 2>/dev/null`
+	version=$(git describe --exact-match 2>/dev/null)
 	if [ -z "$version" ];
 	then
-		version=`git describe 2>/dev/null`
+		version=$(git describe 2>/dev/null)
 	fi
 	if [ -z "$version" ];
 	then
-		version=`git rev-parse --verify --short HEAD 2>/dev/null`
+		version=$(git rev-parse --verify --short HEAD 2>/dev/null)
 	fi
 	if [ ! -z "$EXTRA_VERSION" ];
 	then
@@ -34,14 +34,14 @@ then
 			version="$version-$USER"
 		fi
 		version="$version-dirty"
-		diffsha=`git diff|sha1sum`
-		diffsha=`cut -c-7 <<< "$diffsha"`
+		diffsha=$(git diff|sha1sum)
+		diffsha=$(cut -c-7 <<< "$diffsha")
 		version="$version-$diffsha"
 	fi
 
 	if [ $# -eq 1 ];
 	then
-		version=`echo $version | sed s/skiboot/$1/`
+		version=$(echo $version | sed s/skiboot/$1/)
 	fi
 
 	echo $version
diff --git a/opal-ci/build-centos7.sh b/opal-ci/build-centos7.sh
index b1234b37eec2..44733345b827 100755
--- a/opal-ci/build-centos7.sh
+++ b/opal-ci/build-centos7.sh
@@ -7,15 +7,15 @@ set -vx
 # We're limited as to what we want to bother to run on CentOS7
 # It's fairly old and some of the things (e.g. build+run qemu) we don't
 # want to bother doing.
-if [ `arch` == "x86_64" ]; then
+if [ $(arch) == "x86_64" ]; then
     export CROSS=/opt/cross/gcc-4.8.0-nolibc/powerpc64-linux/bin/powerpc64-linux-
 fi
 # Note that this doesn't work on centos7 because "/lib64/ld64.so.2: version `GLIBC_2.22' not found"
-if [ `arch` == "ppc64le" ]; then
+if [ $(arch) == "ppc64le" ]; then
     export CROSS=/opt/cross/gcc-4.9.4-nolibc/powerpc64-linux/bin/powerpc64-linux-
 fi
 
-MAKE_J=`grep -c processor /proc/cpuinfo`
+MAKE_J=$(grep -c processor /proc/cpuinfo)
 
 make -j${MAKE_J} all
 make -j${MAKE_J} check
@@ -28,5 +28,5 @@ SKIBOOT_GCOV=1 make -j${MAKE_J} check
 make clean
 rm -rf builddir
 mkdir builddir
-make SRC=`pwd` -f ../Makefile -C builddir -j${MAKE_J}
+make SRC=$(pwd) -f ../Makefile -C builddir -j${MAKE_J}
 make clean
diff --git a/opal-ci/build-fedora27.sh b/opal-ci/build-fedora27.sh
index be08259231eb..02ac4280babb 100755
--- a/opal-ci/build-fedora27.sh
+++ b/opal-ci/build-fedora27.sh
@@ -4,7 +4,7 @@ set -uo pipefail
 set -e
 set -vx
 
-MAKE_J=`grep -c processor /proc/cpuinfo`
+MAKE_J=$(grep -c processor /proc/cpuinfo)
 export CROSS="ccache powerpc64-linux-gnu-"
 
 make -j${MAKE_J} all
@@ -21,5 +21,5 @@ make clean
 make clean
 rm -rf builddir
 mkdir builddir
-make SRC=`pwd` -f ../Makefile -C builddir -j${MAKE_J}
+make SRC=$(pwd) -f ../Makefile -C builddir -j${MAKE_J}
 make clean
diff --git a/opal-ci/build-qemu-powernv.sh b/opal-ci/build-qemu-powernv.sh
index 58a89778be1a..5c61aa720ddc 100755
--- a/opal-ci/build-qemu-powernv.sh
+++ b/opal-ci/build-qemu-powernv.sh
@@ -8,4 +8,4 @@ git submodule update --init dtc
 export CC="ccache gcc"
 export CXX="ccache g++"
 ./configure --target-list=ppc64-softmmu --disable-werror
-make -j `grep -c processor /proc/cpuinfo`
+make -j $(grep -c processor /proc/cpuinfo)
diff --git a/opal-ci/build-ubuntu-16.04.sh b/opal-ci/build-ubuntu-16.04.sh
index 053e7e2aea0a..06a9b484f98f 100755
--- a/opal-ci/build-ubuntu-16.04.sh
+++ b/opal-ci/build-ubuntu-16.04.sh
@@ -4,13 +4,13 @@ set -uo pipefail
 set -e
 set -vx
 
-MAKE_J=`grep -c processor /proc/cpuinfo`
+MAKE_J=$(grep -c processor /proc/cpuinfo)
 
 export CROSS="ccache powerpc64le-linux-gnu-"
 
 make -j${MAKE_J} all
 (cd opal-ci; ./build-qemu-powernv.sh)
-export QEMU_BIN=`pwd`/opal-ci/qemu/ppc64-softmmu/qemu-system-ppc64
+export QEMU_BIN=$(pwd)/opal-ci/qemu/ppc64-softmmu/qemu-system-ppc64
 ./opal-ci/fetch-debian-jessie-installer.sh
 make -j${MAKE_J} check
 (make clean; cd external/gard && CROSS= make -j${MAKE_J})
@@ -30,5 +30,5 @@ SKIBOOT_GCOV=1 make -j${MAKE_J} check
 make clean
 rm -rf builddir
 mkdir builddir
-make SRC=`pwd` -f ../Makefile -C builddir -j${MAKE_J}
+make SRC=$(pwd) -f ../Makefile -C builddir -j${MAKE_J}
 make clean
diff --git a/opal-ci/build-ubuntu-18.04.sh b/opal-ci/build-ubuntu-18.04.sh
index 7bcd2d502769..2786600f37bf 100755
--- a/opal-ci/build-ubuntu-18.04.sh
+++ b/opal-ci/build-ubuntu-18.04.sh
@@ -4,7 +4,7 @@ set -uo pipefail
 set -e
 set -vx
 
-MAKE_J=`grep -c processor /proc/cpuinfo`
+MAKE_J=$(grep -c processor /proc/cpuinfo)
 
 export CROSS="ccache powerpc64le-linux-gnu-"
 
@@ -28,7 +28,7 @@ SKIBOOT_GCOV=1 make -j${MAKE_J} check
 make clean
 rm -rf builddir
 mkdir builddir
-make SRC=`pwd` -f ../Makefile -C builddir -j${MAKE_J}
+make SRC=$(pwd) -f ../Makefile -C builddir -j${MAKE_J}
 make clean
 
 echo "Building with clang..."
diff --git a/test/hello_world/run_mambo_hello_world.sh b/test/hello_world/run_mambo_hello_world.sh
index 13112d000405..54d445b18943 100755
--- a/test/hello_world/run_mambo_hello_world.sh
+++ b/test/hello_world/run_mambo_hello_world.sh
@@ -19,19 +19,19 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping hello_world test';
     exit 0;
 fi
 
 if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
-    export SKIBOOT_ZIMAGE=`pwd`/test/hello_world/hello_kernel/hello_kernel.stb
+    export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel.stb
 else
-    export SKIBOOT_ZIMAGE=`pwd`/test/hello_world/hello_kernel/hello_kernel
+    export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
 fi
 
 # Currently getting some core dumps from mambo, so disable them!
-OLD_ULIMIT_C=`ulimit -c`
+OLD_ULIMIT_C=$(ulimit -c)
 ulimit -c 0
 
 t=$(mktemp) || exit 1
diff --git a/test/hello_world/run_mambo_p9_hello_world.sh b/test/hello_world/run_mambo_p9_hello_world.sh
index f8b0dae880d8..9560527a0c2a 100755
--- a/test/hello_world/run_mambo_p9_hello_world.sh
+++ b/test/hello_world/run_mambo_p9_hello_world.sh
@@ -18,19 +18,19 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping hello_world test';
     exit 0;
 fi
 
 if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
-    export SKIBOOT_ZIMAGE=`pwd`/test/hello_world/hello_kernel/hello_kernel.stb
+    export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel.stb
 else
-    export SKIBOOT_ZIMAGE=`pwd`/test/hello_world/hello_kernel/hello_kernel
+    export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
 fi
 
 # Currently getting some core dumps from mambo, so disable them!
-OLD_ULIMIT_C=`ulimit -c`
+OLD_ULIMIT_C=$(ulimit -c)
 ulimit -c 0
 
 t=$(mktemp) || exit 1
diff --git a/test/hello_world/run_qemu_hello_world.sh b/test/hello_world/run_qemu_hello_world.sh
index 3f0aa55a8a77..e8d317607392 100755
--- a/test/hello_world/run_qemu_hello_world.sh
+++ b/test/hello_world/run_qemu_hello_world.sh
@@ -5,7 +5,7 @@ if [ -z "$QEMU_BIN" ]; then
     QEMU_BIN="qemu-system-ppc64"
 fi
 
-if [ ! `command -v $QEMU_BIN` ]; then
+if [ ! $(command -v $QEMU_BIN) ]; then
     echo "Could not find executable QEMU_BIN ($QEMU_BIN). Skipping hello_world test";
     exit 0;
 fi
@@ -15,13 +15,13 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping hello_world test';
     exit 0;
 fi
 
 
-export SKIBOOT_ZIMAGE=`pwd`/test/hello_world/hello_kernel/hello_kernel
+export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
 
 t=$(mktemp) || exit 1
 
diff --git a/test/make-boot-coverage-report.sh b/test/make-boot-coverage-report.sh
index c4d5a0d0e7e1..210880ee62e5 100755
--- a/test/make-boot-coverage-report.sh
+++ b/test/make-boot-coverage-report.sh
@@ -2,7 +2,7 @@
 
 # We cheat and do this in a shell script so I don't go Makefile crazy.
 
-SKIBOOT_GCOV_ADDR=`perl -e "printf '0x%x', 0x30000000 + 0x\`grep gcov_info_list skiboot.map|cut -f 1 -d ' '\`"`
+SKIBOOT_GCOV_ADDR=$(perl -e "printf '0x%x', 0x30000000 + 0x$(grep gcov_info_list skiboot.map|cut -f 1 -d ' ')")
 
 LCOV_INFO_FILES=""
 
diff --git a/test/run_mambo_boot_test.sh b/test/run_mambo_boot_test.sh
index fe0be0e3b63f..adff1804dddb 100755
--- a/test/run_mambo_boot_test.sh
+++ b/test/run_mambo_boot_test.sh
@@ -19,13 +19,13 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping hello_world test';
     exit 0;
 fi
 
 if [ -z "$SKIBOOT_ZIMAGE" ]; then
-    export SKIBOOT_ZIMAGE=`pwd`/zImage.epapr
+    export SKIBOOT_ZIMAGE=$(pwd)/zImage.epapr
 fi
 
 if [ ! -f "$SKIBOOT_ZIMAGE" ]; then
@@ -38,7 +38,7 @@ if [ -z "$SKIBOOT_MEM_DUMP" ]; then
 fi
 
 # Currently getting some core dumps from mambo, so disable them!
-OLD_ULIMIT_C=`ulimit -c`
+OLD_ULIMIT_C=$(ulimit -c)
 ulimit -c 0
 
 t=$(mktemp) || exit 1
diff --git a/test/run_qemu-jessie-debian-installer_boot_test.sh b/test/run_qemu-jessie-debian-installer_boot_test.sh
index 63c4d299e539..652ca3811aed 100755
--- a/test/run_qemu-jessie-debian-installer_boot_test.sh
+++ b/test/run_qemu-jessie-debian-installer_boot_test.sh
@@ -5,7 +5,7 @@ if [ -z "$QEMU_BIN" ]; then
     QEMU_BIN="qemu-system-ppc64"
 fi
 
-if [ ! `command -v $QEMU_BIN` ]; then
+if [ ! $(command -v $QEMU_BIN) ]; then
     echo "Could not find executable QEMU_BIN ($QEMU_BIN). Skipping hello_world test";
     exit 0;
 fi
@@ -15,7 +15,7 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping boot test';
     exit 0;
 fi
@@ -30,8 +30,8 @@ if [ ! -f debian-jessie-initrd.gz ]; then
     exit 0;
 fi
 
-T=`mktemp  --tmpdir skiboot_qemu_debian-jessie-boot_test.XXXXXXXXXX`
-#D=`mktemp  --tmpdir debian-jessie-install.qcow2.XXXXXXXXXX`
+T=$(mktemp  --tmpdir skiboot_qemu_debian-jessie-boot_test.XXXXXXXXXX)
+#D=$(mktemp  --tmpdir debian-jessie-install.qcow2.XXXXXXXXXX)
 
 # In future we should do full install:
 # FIXME: -append "DEBIAN_FRONTEND=text locale=en_US keymap=us hostname=OPALtest domain=unassigned-domain rescue/enable=true"
diff --git a/test/run_qemu_boot_test.sh b/test/run_qemu_boot_test.sh
index bfcf4851244e..08bb65aa6199 100755
--- a/test/run_qemu_boot_test.sh
+++ b/test/run_qemu_boot_test.sh
@@ -5,7 +5,7 @@ if [ -z "$QEMU_BIN" ]; then
     QEMU_BIN="qemu-system-ppc64"
 fi
 
-if [ ! `command -v $QEMU_BIN` ]; then
+if [ ! $(command -v $QEMU_BIN) ]; then
     echo "Could not find executable QEMU_BIN ($QEMU_BIN). Skipping hello_world test";
     exit 0;
 fi
@@ -15,13 +15,13 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping hello_world test';
     exit 0;
 fi
 
 if [ -z "$SKIBOOT_ZIMAGE" ]; then
-    export SKIBOOT_ZIMAGE=`pwd`/zImage.epapr
+    export SKIBOOT_ZIMAGE=$(pwd)/zImage.epapr
 fi
 
 if [ ! -f "$SKIBOOT_ZIMAGE" ]; then
@@ -29,7 +29,7 @@ if [ ! -f "$SKIBOOT_ZIMAGE" ]; then
     exit 0;
 fi
 
-T=`mktemp  --tmpdir skiboot_qemu_boot_test.XXXXXXXXXX`
+T=$(mktemp  --tmpdir skiboot_qemu_boot_test.XXXXXXXXXX)
 
 ( cat <<EOF | expect
 set timeout 600
diff --git a/test/sreset_world/run_mambo_p9_sreset.sh b/test/sreset_world/run_mambo_p9_sreset.sh
index 9f61f1e9b41a..926ce3e49d3e 100755
--- a/test/sreset_world/run_mambo_p9_sreset.sh
+++ b/test/sreset_world/run_mambo_p9_sreset.sh
@@ -18,19 +18,19 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping sreset_world test';
     exit 0;
 fi
 
 if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
-    export SKIBOOT_ZIMAGE=`pwd`/test/sreset_world/sreset_kernel/sreset_kernel.stb
+    export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel.stb
 else
-    export SKIBOOT_ZIMAGE=`pwd`/test/sreset_world/sreset_kernel/sreset_kernel
+    export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel
 fi
 
 # Currently getting some core dumps from mambo, so disable them!
-OLD_ULIMIT_C=`ulimit -c`
+OLD_ULIMIT_C=$(ulimit -c)
 ulimit -c 0
 
 t=$(mktemp) || exit 1
diff --git a/test/sreset_world/run_mambo_sreset.sh b/test/sreset_world/run_mambo_sreset.sh
index 10c7224de3c8..8fba5eb9ea0f 100755
--- a/test/sreset_world/run_mambo_sreset.sh
+++ b/test/sreset_world/run_mambo_sreset.sh
@@ -19,19 +19,19 @@ if [ -n "$KERNEL" ]; then
     exit 0;
 fi
 
-if [ ! `command -v expect` ]; then
+if [ ! $(command -v expect) ]; then
     echo 'Could not find expect binary. Skipping sreset_world test';
     exit 0;
 fi
 
 if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
-    export SKIBOOT_ZIMAGE=`pwd`/test/sreset_world/sreset_kernel/sreset_kernel.stb
+    export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel.stb
 else
-    export SKIBOOT_ZIMAGE=`pwd`/test/sreset_world/sreset_kernel/sreset_kernel
+    export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel
 fi
 
 # Currently getting some core dumps from mambo, so disable them!
-OLD_ULIMIT_C=`ulimit -c`
+OLD_ULIMIT_C=$(ulimit -c)
 ulimit -c 0
 
 t=$(mktemp) || exit 1
-- 
2.17.1



More information about the Skiboot mailing list