From a0b273b0317bbfc748435a1ebc80d1d589f9d479 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 5 Oct 2017 13:58:46 +0100 Subject: [PATCH] shutil: fix read_tree_values and hotplug_online_all for sh read_tree_values and hotplug_online_all relied on () array evaluation which is a Bash thing and is broken in sh; this fixes things for sh. --- devlib/bin/scripts/shutils.in | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/devlib/bin/scripts/shutils.in b/devlib/bin/scripts/shutils.in index 024e891..007d0a5 100755 --- a/devlib/bin/scripts/shutils.in +++ b/devlib/bin/scripts/shutils.in @@ -200,8 +200,7 @@ cgroups_freezer_set_state() { ################################################################################ hotplug_online_all() { - PATHS=(/sys/devices/system/cpu/cpu[0-9]*) - for path in "${PATHS[@]}"; do + for path in /sys/devices/system/cpu/cpu[0-9]*; do if [ $(cat $path/online) -eq 0 ]; then echo 1 > $path/online fi @@ -213,17 +212,21 @@ hotplug_online_all() { ################################################################################ read_tree_values() { - PATH=$1 + BASEPATH=$1 MAXDEPTH=$2 - if [ ! -e $PATH ]; then - echo "ERROR: $PATH does not exist" + if [ ! -e $BASEPATH ]; then + echo "ERROR: $BASEPATH does not exist" exit 1 fi - PATHS=($($BUSYBOX find $PATH -follow -maxdepth $MAXDEPTH)) - if [ ${#PATHS[@]} -gt 1 ]; then - $BUSYBOX grep -s '' ${PATHS[@]} + PATHS=$($BUSYBOX find $BASEPATH -follow -maxdepth $MAXDEPTH) + i=0 + for path in $PATHS; do + i=$(expr $i + 1) + done + if [ $i -gt 1 ]; then + $BUSYBOX grep -s '' $PATHS fi }