Skip to contentSkip to conversation

cpuhotplug_hotplug.sh: dash's 'local' only accepts the first token

PATCH New James Morse 2 participants 2 messages Oct 18, 2016 – Oct 24, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuhotplug_hotplug.sh: dash's 'local' only accepts the first token

dash's 'local' only accepts the first token, the line:

Quoted 1 line

local present_cpus=$(get_present_cpus)

causes a world of problems on systems where /bin/sh is dash:

Quoted 6 lines
root@juno-r1:~# /bin/sh
# get_hotplug_cpus
/bin/sh: 1: get_hotplug_cpus: not found
# . /opt/ltp/testcases/bin/cpuhotplug_hotplug.sh
# get_hotplug_cpus
cpu0

when compared with bash:

Quoted 5 lines
root@juno-r1:~# get_hotplug_cpus
get_hotplug_cpus: command not found
root@juno-r1:~# . /opt/ltp/testcases/bin/cpuhotplug_hotplug.sh
root@juno-r1:~# get_hotplug_cpus
cpu0 cpu1 cpu2 cpu3 cpu4 cpu5

This causes the cpuhotplug tests to behave really strangely....

Quoting the assignment fixes the issue:

root@juno-r1:~# /bin/sh
Quoted 5 lines
# get_hotplug_cpus
/bin/sh: 1: get_hotplug_cpus: not found
# . /opt/ltp/testcases/bin/cpuhotplug_hotplug.sh
# get_hotplug_cpus
cpu0 cpu1 cpu2 cpu3 cpu4 cpu5
---
 testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh +1 -1
index 3967937..9165d3c 100644
@@ -214,7 +214,7 @@ get_present_cpus_num()
 #
 get_hotplug_cpus()
 {
-    local present_cpus=$(get_present_cpus)
+    local present_cpus="$(get_present_cpus)"
     local hotplug_cpus=""
 
     for cpu in $present_cpus; do
Signature · 1 line
2.8.0.rc3
#1 lore raw

PATCH 1/1 cpuhotplug_hotplug.sh: dash's 'local' only accepts the first token

Hi!
Pushed, thanks.

Signature · 2 lines
Cyril Hrubis
[email protected]