toolchain-scripts: replace `` by $()

Submitted by Jens Rehsack on Oct. 13, 2020, 11:43 a.m. | Patch ID: 177186

Details

Message ID 20201013114350.3078-1-sno@NetBSD.org
State New
Headers show

Commit Message

Jens Rehsack Oct. 13, 2020, 11:43 a.m.
From: Jens Rehsack <sno@netbsd.org>

Replace backticks (``) in toolchain-scripts with $() to separate 'style'
changes from technical changes when stacking is needed.
Most shell script coding styles meanwhile encourage $() ...

Signed-off-by: Jens Rehsack <sno@netbsd.org>
---
 meta/classes/toolchain-scripts.bbclass |  6 +++---
 meta/files/toolchain-shar-extract.sh   | 14 +++++++-------
 meta/files/toolchain-shar-relocate.sh  |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/toolchain-scripts.bbclass b/meta/classes/toolchain-scripts.bbclass
index db1d3215ef..d0e0c1aad3 100644
--- a/meta/classes/toolchain-scripts.bbclass
+++ b/meta/classes/toolchain-scripts.bbclass
@@ -66,7 +66,7 @@  toolchain_create_tree_env_script () {
 	script=${TMPDIR}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
 	rm -f $script
 	touch $script
-	echo 'orig=`pwd`; cd ${COREBASE}; . ./oe-init-build-env ${TOPDIR}; cd $orig' >> $script
+	echo 'orig=$(pwd); cd ${COREBASE}; . ./oe-init-build-env ${TOPDIR}; cd $orig' >> $script
 	echo 'export PATH=${STAGING_DIR_NATIVE}/usr/bin:${STAGING_BINDIR_TOOLCHAIN}:$PATH' >> $script
 	echo 'export PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR}' >> $script
 	echo 'export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}' >> $script
@@ -178,8 +178,8 @@  toolchain_create_sdk_siteconfig () {
 	for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do
 		# Resolve virtual/* names to the real recipe name using sysroot-providers info
 		case $sitefile in virtual/*)
-			sitefile=`echo $sitefile | tr / _`
-			sitefile=`cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile`
+			sitefile=$(echo $sitefile | tr / _)
+			sitefile=$(cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile)
 		esac
 
 		if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then
diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh
index 04527f891f..1ae1aff15e 100644
--- a/meta/files/toolchain-shar-extract.sh
+++ b/meta/files/toolchain-shar-extract.sh
@@ -7,7 +7,7 @@  INIT_PYTHON=$(which python3 2>/dev/null )
 [ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1
 
 # Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted
-PATH=`$INIT_PYTHON -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))'`
+PATH=$($INIT_PYTHON -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))')
 
 tweakpath () {
     case ":${PATH}:" in
@@ -30,14 +30,14 @@  INST_GCC_VER=$(gcc --version | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/
 SDK_GCC_VER='@SDK_GCC_VER@'
 
 verlte () {
-	[  "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ]
+	[  "$1" = "$(printf "$1\n$2" | sort -V | head -n1)" ]
 }
 
 verlt() {
 	[ "$1" = "$2" ] && return 1 || verlte $1 $2
 }
 
-verlt `uname -r` @OLDEST_KERNEL@
+verlt $(uname -r) @OLDEST_KERNEL@
 if [ $? = 0 ]; then
 	echo "Error: The SDK needs a kernel > @OLDEST_KERNEL@"
 	exit 1
@@ -178,9 +178,9 @@  if [ "$SDK_EXTENSIBLE" = "1" ]; then
 	# The build system doesn't work well with /tmp on NFS
 	fs_dev_path="$target_sdk_dir"
 	while [ ! -d "$fs_dev_path" ] ; do
-		fs_dev_path=`dirname $fs_dev_path`
+		fs_dev_path=$(dirname $fs_dev_path)
         done
-	fs_dev_type=`stat -f -c '%t' "$fs_dev_path"`
+	fs_dev_type=$(stat -f -c '%t' "$fs_dev_path")
 	if [ "$fsdevtype" = "6969" ] ; then
 		echo "The target directory path $target_sdk_dir is on NFS, this is not possible. Abort!"
 		exit 1
@@ -256,7 +256,7 @@  echo "done"
 printf "Setting it up..."
 # fix environment paths
 real_env_setup_script=""
-for env_setup_script in `ls $target_sdk_dir/environment-setup-*`; do
+for env_setup_script in $(ls $target_sdk_dir/environment-setup-*); do
 	if grep -q 'OECORE_NATIVE_SYSROOT=' $env_setup_script; then
 		# Handle custom env setup scripts that are only named
 		# environment-setup-* so that they have relocation
@@ -288,7 +288,7 @@  fi
 
 echo "SDK has been successfully set up and is ready to be used."
 echo "Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g."
-for env_setup_script in `ls $target_sdk_dir/environment-setup-*`; do
+for env_setup_script in $(ls $target_sdk_dir/environment-setup-*); do
 	echo " \$ . $env_setup_script"
 done
 
diff --git a/meta/files/toolchain-shar-relocate.sh b/meta/files/toolchain-shar-relocate.sh
index e3c10018ef..f529a96da3 100644
--- a/meta/files/toolchain-shar-relocate.sh
+++ b/meta/files/toolchain-shar-relocate.sh
@@ -17,7 +17,7 @@  if [ "x$executable_files" = "x" ]; then
    exit 1
 fi
 
-tdir=`mktemp -d`
+tdir=$(mktemp -d)
 if [ x$tdir = x ] ; then
    echo "SDK relocate failed, could not create a temporary directory"
    exit 1
@@ -26,7 +26,7 @@  cat <<EOF >> $tdir/relocate_sdk.sh
 #!/bin/sh
 for py in python python2 python3
 do
-	PYTHON=\`which \${py} 2>/dev/null\`
+	PYTHON=\$(which \${py} 2>/dev/null)
 	if [ \$? -eq 0 ]; then
 		break;
 	fi