[bitbake-devel,v3,4/4] build: fix shell trap syntax errors in dash; ShellCheck warnings

Submitted by Chris Laplante via lists.openembedded.org on Aug. 10, 2020, 4:55 p.m. | Patch ID: 175195

Details

Message ID 20200810165524.37417-5-chris.laplante@agilent.com
State Master Next
Commit 285c6782538eb5521c201f7ce05fc4af44ba337a
Headers show

Commit Message

---
 lib/bb/build.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/build.py b/lib/bb/build.py
index a6b7c5de..060fc568 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -320,14 +320,14 @@  bb_bash_exit_handler() {
         echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from '$BASH_COMMAND'"
 
         echo "WARNING: Backtrace (BB generated script): "
-        for ((i=1; i<${#FUNCNAME[@]}; i++)); do
-            if [ $i -eq 1 ]; then
+        for i in $(seq 1 $((${#FUNCNAME[@]} - 1))); do
+            if [ "$i" -eq 1 ]; then
                 # TODO: maybe manually track LINENO with a DEBUG trap?
                 # LINENO / BASH_LINENO for the first frame in an EXIT trap is wrong :/
                 # http://gnu-bash.2382.n7.nabble.com/trap-echo-quot-trap-exit-on-LINENO-quot-EXIT-gt-wrong-linenumber-td3666.html
-                echo "\t#$((i)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ?"
+                echo -e "\t#$((i)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ?"
             else
-                echo "\t#$((i)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ${BASH_LINENO[$((i-1))]}"
+                echo -e "\t#$((i)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ${BASH_LINENO[$((i-1))]}"
             fi
         done
     fi
@@ -339,8 +339,8 @@  bb_bash_err_handler() {
     echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from '$BASH_COMMAND'"
 
     echo "WARNING: Backtrace (BB generated script): "
-    for ((i=1; i<${#FUNCNAME[@]}; i++)); do
-        echo "\t#$((i-1)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ${BASH_LINENO[$((i-1))]}"
+    for i in $(seq 1 $((${#FUNCNAME[@]} - 1))); do
+        echo -e "\t#$((i-1)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ${BASH_LINENO[$((i-1))]}"
     done
 
     trap "" EXIT