@@ -52,7 +52,7 @@ python -c "$replace_script"
5252
5353if  [ " $GITHUB_REPOSITORY " ==  " espressif/arduino-esp32" ;   then 
5454    echo  " Linking Core..." 
55-     ln -s $GITHUB_WORKSPACE  " $PLATFORMIO_ESP32_PATH " 
55+     ln -s " $GITHUB_WORKSPACE " " $PLATFORMIO_ESP32_PATH " 
5656else 
5757    echo  " Cloning Core Repository ..." 
5858    git clone --recursive https://github.com/espressif/arduino-esp32.git " $PLATFORMIO_ESP32_PATH " >  /dev/null 2>&1 
6161echo  " PlatformIO for ESP32 has been installed" 
6262echo  " " 
6363
64- function  build_pio_sketch() {  #  build_pio_sketch <board> <options> <path-to-ino>
64+ function  build_pio_sketch   { #  build_pio_sketch <board> <options> <path-to-ino>
6565    if  [ " $# " -lt  3 ];  then 
6666        echo  " ERROR: Illegal number of parameters" 
6767        echo  " USAGE: build_pio_sketch <board> <options> <path-to-ino>" 
@@ -71,13 +71,15 @@ function build_pio_sketch(){ # build_pio_sketch <board> <options> <path-to-ino>
7171    local  board=" $1 " 
7272    local  options=" $2 " 
7373    local  sketch=" $3 " 
74-     local  sketch_dir=$( dirname " $sketch " ) 
74+     local  sketch_dir
75+ 
76+     sketch_dir=$( dirname " $sketch " ) 
7577    echo  " " 
76-     echo  " Compiling '" $( basename " $sketch " ) " ' ..." 
78+     echo  " Compiling '$( basename " $sketch " ) " 
7779    python -m platformio ci --board " $board " " $sketch_dir " " $options " 
7880}
7981
80- function  build_pio_sketches() {  #  build_pio_sketches <board> <options> <examples-path> <chunk> <total-chunks>
82+ function  build_pio_sketches   { #  build_pio_sketches <board> <options> <examples-path> <chunk> <total-chunks>
8183    if  [ " $# " -lt  3 ];  then 
8284        echo  " ERROR: Illegal number of parameters" 
8385        echo  " USAGE: build_pio_sketches <board> <options> <examples-path> [<chunk> <total-chunks>]" 
@@ -108,27 +110,34 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
108110    ${COUNT_SKETCHES}  " $examples " " esp32" 
109111    local  sketchcount=$? 
110112    set  -e
111-     local  sketches=$( cat sketches.txt) 
113+     local  sketches
114+     sketches=$( cat sketches.txt) 
112115    rm -rf sketches.txt
113116
114-     local  chunk_size=$((  $sketchcount  /  $chunks_num  )) 
115-     local  all_chunks=$((  $chunks_num  *  $chunk_size  )) 
117+     local  chunk_size
118+     local  all_chunks
119+     local  start_index
120+     local  end_index
121+     local  start_num
122+ 
123+     chunk_size=$((  sketchcount /  chunks_num )) 
124+     all_chunks=$((  chunks_num *  chunk_size )) 
116125    if  [ " $all_chunks " -lt  " $sketchcount " ;  then 
117-         chunk_size=$((  $ chunk_size+  1  )) 
126+         chunk_size=$((  chunk_size +  1  )) 
118127    fi 
119128
120-     local   start_index=$((  $ chunk_idex*  $ chunk_size)) 
129+     start_index=$((  chunk_idex *  chunk_size )) 
121130    if  [ " $sketchcount " -le  " $start_index " ;  then 
122131        echo  " Skipping job" 
123132        return  0
124133    fi 
125134
126-     local   end_index=$((  $(( $ chunk_idex+  1  )) *  $ chunk_size
135+     end_index=$((  $(( chunk_idex +  1  )) *  chunk_size ))
127136    if  [ " $end_index " -gt  " $sketchcount " ;  then 
128137        end_index=$sketchcount 
129138    fi 
130139
131-     local   start_num=$((  $ start_index+  1  )) 
140+     start_num=$((  start_index +  1  )) 
132141    echo  " Found $sketchcount  Sketches" ; 
133142    echo  " Chunk Count : $chunks_num " 
134143    echo  " Chunk Size  : $chunk_size " 
@@ -137,25 +146,32 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
137146
138147    local  sketchnum=0
139148    for  sketch  in  $sketches ;  do 
140-         local  sketchdir=$( dirname $sketch ) 
141-         local  sketchdirname=$( basename $sketchdir ) 
142-         local  sketchname=$( basename $sketch ) 
149+         local  sketchdir
150+         local  sketchdirname
151+         local  sketchname
152+         local  is_target
153+         local  has_requirements
154+ 
155+         sketchdir=$( dirname " $sketch " ) 
156+         sketchdirname=$( basename " $sketchdir " ) 
157+         sketchname=$( basename " $sketch " ) 
158+ 
143159        if  [[ " $sketchdirname .ino" !=  " $sketchname " ;  then 
144160            continue 
145-         elif  [ -f  $sketchdir /ci.json ];  then 
161+         elif  [ -f  " $sketchdir " ;  then 
146162            #  If the target is listed as false, skip the sketch. Otherwise, include it.
147-             is_target=$( jq -r ' .targets[esp32]' $sketchdir /ci.json) 
163+             is_target=$( jq -r ' .targets[esp32]' " $sketchdir " ) 
148164            if  [[ " $is_target " ==  " false" ;  then 
149165                continue 
150166            fi 
151167
152-             local   has_requirements=$( ${CHECK_REQUIREMENTS}  $sketchdir  " $SDKCONFIG_DIR /esp32/sdkconfig" ) 
168+             has_requirements=$( ${CHECK_REQUIREMENTS}  " $sketchdir " " $SDKCONFIG_DIR /esp32/sdkconfig" ) 
153169            if  [ " $has_requirements " ==  " 0" ;  then 
154170                continue 
155171            fi 
156172        fi 
157173
158-         sketchnum=$(( $ sketchnum+  1 )) 
174+         sketchnum=$(( sketchnum +  1 )) 
159175        if  [ " $sketchnum " -le  " $start_index " 
160176        ||  [ " $sketchnum " -gt  " $end_index " ;  then 
161177            continue 
0 commit comments