diff mbox series

[OpenWrt-Devel,02/10] base-files: replace backticks by $(...)

Message ID 20200510144754.10751-2-freifunk@adrianschmutzler.de
State Superseded
Delegated to: Adrian Schmutzler
Headers show
Series [OpenWrt-Devel,01/10] ltq-vdsl-app: replace backticks by $(...) | expand

Commit Message

Adrian Schmutzler May 10, 2020, 2:47 p.m. UTC
This replaces deprecated backticks by more versatile $(...) syntax.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 package/base-files/files/bin/board_detect        |  2 +-
 .../files/etc/uci-defaults/13_fix-group-user     |  2 +-
 .../files/lib/preinit/30_failsafe_wait           |  2 +-
 package/base-files/files/lib/upgrade/nand.sh     |  8 ++++----
 package/base-files/files/sbin/pkg_check          | 16 ++++++++--------
 5 files changed, 15 insertions(+), 15 deletions(-)

Comments

Adrian Schmutzler May 10, 2020, 4 p.m. UTC | #1
> -	local rootfs_length=`(cat $1 | wc -c) 2> /dev/null`
> +	local rootfs_length=$((cat $1 | wc -c) 2> /dev/null)
> 
>  	nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0"
> 
> @@ -249,8 +249,8 @@ nand_upgrade_tar() {
>  	local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
>  	board_dir=${board_dir%/}
> 
> -	local kernel_length=`(tar xf $tar_file ${board_dir}/kernel -O | wc -c)
> 2> /dev/null`
> -	local rootfs_length=`(tar xf $tar_file ${board_dir}/root -O | wc -c) 2>
> /dev/null`
> +	local kernel_length=$((tar xf $tar_file ${board_dir}/kernel -O | wc -c)
> 2> /dev/null)
> +	local rootfs_length=$((tar xf $tar_file ${board_dir}/root -O | wc -c)
> +2> /dev/null)

This won't work, as discussed here:

https://github.com/openwrt/openwrt/commit/291d79935e9c4a974b037b6bed733ce92d4242e3#diff-a6a780f4082e88756e922a1f3ec5e2ab

Will send an updated version.
diff mbox series

Patch

diff --git a/package/base-files/files/bin/board_detect b/package/base-files/files/bin/board_detect
index 441db6a08f..840bd0178d 100755
--- a/package/base-files/files/bin/board_detect
+++ b/package/base-files/files/bin/board_detect
@@ -5,7 +5,7 @@  CFG=$1
 [ -n "$CFG" ] || CFG=/etc/board.json
 
 [ -d "/etc/board.d/" -a ! -s "$CFG" ] && {
-	for a in `ls /etc/board.d/*`; do
+	for a in $(ls /etc/board.d/*); do
 		[ -x $a ] || continue;
 		$(. $a)
 	done
diff --git a/package/base-files/files/etc/uci-defaults/13_fix-group-user b/package/base-files/files/etc/uci-defaults/13_fix-group-user
index bf9febdfe4..74f501e8f7 100644
--- a/package/base-files/files/etc/uci-defaults/13_fix-group-user
+++ b/package/base-files/files/etc/uci-defaults/13_fix-group-user
@@ -1,6 +1,6 @@ 
 . /lib/functions.sh
 
-for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do
+for file in $(grep -sl Require-User /usr/lib/opkg/info/*.control); do
 	file="${file##*/}"
 	file="${file%.control}"
 	add_group_and_user "${file}"
diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait
index 85dca398fa..a2c2c386aa 100644
--- a/package/base-files/files/lib/preinit/30_failsafe_wait
+++ b/package/base-files/files/lib/preinit/30_failsafe_wait
@@ -91,7 +91,7 @@  failsafe_wait() {
 	grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
 	if [ "$FAILSAFE" != "true" ]; then
 		fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
-		[ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
+		[ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "$(cat /tmp/failsafe_button)" was pressed -"
 		[ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
 	fi
 }
diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh
index e7d7bf8d13..3ae06c6199 100644
--- a/package/base-files/files/lib/upgrade/nand.sh
+++ b/package/base-files/files/lib/upgrade/nand.sh
@@ -231,7 +231,7 @@  nand_upgrade_ubinized() {
 
 # Write the UBIFS image to UBI volume
 nand_upgrade_ubifs() {
-	local rootfs_length=`(cat $1 | wc -c) 2> /dev/null`
+	local rootfs_length=$((cat $1 | wc -c) 2> /dev/null)
 
 	nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0"
 
@@ -249,8 +249,8 @@  nand_upgrade_tar() {
 	local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
 	board_dir=${board_dir%/}
 
-	local kernel_length=`(tar xf $tar_file ${board_dir}/kernel -O | wc -c) 2> /dev/null`
-	local rootfs_length=`(tar xf $tar_file ${board_dir}/root -O | wc -c) 2> /dev/null`
+	local kernel_length=$((tar xf $tar_file ${board_dir}/kernel -O | wc -c) 2> /dev/null)
+	local rootfs_length=$((tar xf $tar_file ${board_dir}/root -O | wc -c) 2> /dev/null)
 
 	local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)"
 
@@ -307,7 +307,7 @@  nand_do_upgrade() {
 nand_do_platform_check() {
 	local board_name="$1"
 	local tar_file="$2"
-	local control_length=`(tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null`
+	local control_length=$((tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null)
 	local file_type="$(identify $2)"
 
 	[ "$control_length" = 0 -a "$file_type" != "ubi" -a "$file_type" != "ubifs" ] && {
diff --git a/package/base-files/files/sbin/pkg_check b/package/base-files/files/sbin/pkg_check
index 9968c9b78e..775e401b26 100755
--- a/package/base-files/files/sbin/pkg_check
+++ b/package/base-files/files/sbin/pkg_check
@@ -72,14 +72,14 @@  while [ "$1" ]; do
 	fi
 	[ $QUIET = yes ] || echo " * Checking package $1:"
 	ERR=""
-	CHECK="`sha256sum -c /usr/lib/opkg/info/$1.files-sha256sum 2> /dev/null`"
+	CHECK="$(sha256sum -c /usr/lib/opkg/info/$1.files-sha256sum 2> /dev/null)"
 
 	# Are the changed files config files?
-	if [ $? -ne 0 ] && [ "`cat "/usr/lib/opkg/info/$1.files-sha256sum"`" ]; then
-		NEWCHECK="`echo "$CHECK" | grep '^.*: OK$'`"
-		for i in `echo "$CHECK" | sed -n 's|^\(.*\): FAILED$|\1|p'`; do
-			if [ "`grep "^$i\$" "/usr/lib/opkg/info/$1.conffiles" 2> /dev/null`" ] || \
-			   [ "`echo "$i" | grep "^/etc/uci-defaults/"`" ]; then
+	if [ $? -ne 0 ] && [ "$(cat "/usr/lib/opkg/info/$1.files-sha256sum")" ]; then
+		NEWCHECK="$(echo "$CHECK" | grep '^.*: OK$')"
+		for i in $(echo "$CHECK" | sed -n 's|^\(.*\): FAILED$|\1|p'); do
+			if [ "$(grep "^$i\$" "/usr/lib/opkg/info/$1.conffiles" 2> /dev/null)" ] || \
+			   [ "$(echo "$i" | grep "^/etc/uci-defaults/")" ]; then
 				NEWCHECK="${NEWCHECK}${NL}${i}: CONFIGURED"
 			else
 				NEWCHECK="${NEWCHECK}${NL}${i}: FAILED"
@@ -91,7 +91,7 @@  while [ "$1" ]; do
 
 	# Do we have changed files or not?
 	if [ -z "$ERR" ]; then
-		[ $QUIET = yes ] || [ -z "`cat "/usr/lib/opkg/info/$1.files-sha256sum"`" ] || echo "$CHECK" | sed 's|^|   - |'
+		[ $QUIET = yes ] || [ -z "$(cat "/usr/lib/opkg/info/$1.files-sha256sum")" ] || echo "$CHECK" | sed 's|^|   - |'
 		[ $QUIET = yes ] || echo " * Package $1 is ok"
 		[ $QUIET = yes ] || echo
 	else
@@ -107,7 +107,7 @@  while [ "$1" ]; do
 			echo "Exiting on first change found!"
 			exit 1
 		fi
-		for i in `echo "$CHECK" | sed -n 's|^\(.*\): FAILED$|\1|p'`; do
+		for i in $(echo "$CHECK" | sed -n 's|^\(.*\): FAILED$|\1|p'); do
 			SUMMARY="${SUMMARY}${NL} - $1: $i"
 		done
 		echo