Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b3d15f9

Browse filesBrowse files
committed
fix(formatting): Fix bash scripts
1 parent 73e30b4 commit b3d15f9
Copy full SHA for b3d15f9

19 files changed

+702
-584
lines changed

‎.github/scripts/check-cmakelists.sh

Copy file name to clipboardExpand all lines: .github/scripts/check-cmakelists.sh
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
23
#
34
# This script is used in the CI workflow. It checks all non-examples source files in libraries/ and cores/ are listed in
45
# CMakeLists.txt for the cmake-based IDF component
@@ -12,10 +13,10 @@ set -e
1213
git submodule update --init --recursive
1314

1415
# find all source files in repo
15-
REPO_SRCS=`find cores/esp32/ libraries/ -name 'examples' -prune -o -name '*.c' -print -o -name '*.cpp' -print | sort`
16+
REPO_SRCS=$(find cores/esp32/ libraries/ -name 'examples' -prune -o -name '*.c' -print -o -name '*.cpp' -print | sort)
1617

1718
# find all source files named in CMakeLists.txt COMPONENT_SRCS
18-
CMAKE_SRCS=`cmake --trace-expand -P CMakeLists.txt 2>&1 | grep set\(srcs | cut -d'(' -f3 | sed 's/ )//' | sed 's/srcs //' | tr ' ;' '\n' | sort`
19+
CMAKE_SRCS=$(cmake --trace-expand -P CMakeLists.txt 2>&1 | grep set\(srcs | cut -d'(' -f3 | sed 's/ )//' | sed 's/srcs //' | tr ' ;' '\n' | sort)
1920

2021
if ! diff -u0 --label "Repo Files" --label "srcs" <(echo "$REPO_SRCS") <(echo "$CMAKE_SRCS"); then
2122
echo "Source files in repo (-) and source files in CMakeLists.txt (+) don't match"

‎.github/scripts/find_all_boards.sh

Copy file name to clipboardExpand all lines: .github/scripts/find_all_boards.sh
+12-13Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# Get all boards
44
boards_array=()
55

6-
for line in `grep '.tarch=' boards.txt`; do
6+
boards_list=$(grep '.tarch=' boards.txt)
7+
8+
while read -r line; do
79
board_name=$(echo "$line" | cut -d '.' -f1 | cut -d '#' -f1)
810
# skip esp32c2 as we dont build libs for it
911
if [ "$board_name" == "esp32c2" ]; then
@@ -12,29 +14,26 @@ for line in `grep '.tarch=' boards.txt`; do
1214
fi
1315
boards_array+=("espressif:esp32:$board_name")
1416
echo "Added 'espressif:esp32:$board_name' to array"
15-
done
17+
done <<< "$boards_list"
1618

1719
# Create JSON like string with all boards found and pass it to env variable
1820
board_count=${#boards_array[@]}
1921
echo "Boards found: $board_count"
20-
echo "BOARD-COUNT=$board_count" >> $GITHUB_ENV
22+
echo "BOARD-COUNT=$board_count" >> "$GITHUB_ENV"
2123

22-
if [ $board_count -gt 0 ]
23-
then
24+
if [ "$board_count" -gt 0 ]; then
2425
json_matrix='['
25-
for board in ${boards_array[@]}
26-
do
26+
for board in "${boards_array[@]}"; do
2727
json_matrix+='"'$board'"'
28-
if [ $board_count -gt 1 ]
29-
then
28+
if [ "$board_count" -gt 1 ]; then
3029
json_matrix+=","
3130
fi
32-
board_count=$(($board_count - 1))
31+
board_count=$((board_count - 1))
3332
done
3433
json_matrix+=']'
3534

36-
echo $json_matrix
37-
echo "FQBNS=${json_matrix}" >> $GITHUB_ENV
35+
echo "$json_matrix"
36+
echo "FQBNS=${json_matrix}" >> "$GITHUB_ENV"
3837
else
39-
echo "FQBNS=" >> $GITHUB_ENV
38+
echo "FQBNS=" >> "$GITHUB_ENV"
4039
fi

‎.github/scripts/find_new_boards.sh

Copy file name to clipboardExpand all lines: .github/scripts/find_new_boards.sh
+15-22Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ owner_repository=$1
55
base_ref=$2
66

77
# Download the boards.txt file from the base branch
8-
curl -L -o boards_base.txt https://raw.githubusercontent.com/$owner_repository/$base_ref/boards.txt
8+
curl -L -o boards_base.txt https://raw.githubusercontent.com/"$owner_repository"/"$base_ref"/boards.txt
99

1010
# Compare boards.txt file in the repo with the modified file from PR
1111
diff=$(diff -u boards_base.txt boards.txt)
1212

1313
# Check if the diff is empty
14-
if [ -z "$diff" ]
15-
then
14+
if [ -z "$diff" ]; then
1615
echo "No changes in boards.txt file"
1716
echo "FQBNS="
1817
exit 0
@@ -21,23 +20,20 @@ fi
2120
# Extract added or modified lines (lines starting with '+' or '-')
2221
modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]')
2322

24-
# Print the modified lines for debugging
23+
# Print the modified lines for debugging
2524
echo "Modified lines:"
2625
echo "$modified_lines"
2726

2827
boards_array=()
2928
previous_board=""
3029

3130
# Extract board names from the modified lines, and add them to the boards_array
32-
while read -r line
33-
do
31+
while read -r line; do
3432
board_name=$(echo "$line" | cut -d '.' -f1 | cut -d '#' -f1)
3533
# remove + or - from the board name at the beginning
36-
board_name=$(echo "$board_name" | sed 's/^[+-]//')
37-
if [ "$board_name" != "" ] && [ "$board_name" != "+" ] && [ "$board_name" != "-" ] && [ "$board_name" != "esp32_family" ]
38-
then
39-
if [ "$board_name" != "$previous_board" ]
40-
then
34+
board_name=${board_name#[-+]}
35+
if [ "$board_name" != "" ] && [ "$board_name" != "+" ] && [ "$board_name" != "-" ] && [ "$board_name" != "esp32_family" ]; then
36+
if [ "$board_name" != "$previous_board" ]; then
4137
boards_array+=("espressif:esp32:$board_name")
4238
previous_board="$board_name"
4339
echo "Added 'espressif:esp32:$board_name' to array"
@@ -48,22 +44,19 @@ done <<< "$modified_lines"
4844
# Create JSON like string with all boards found and pass it to env variable
4945
board_count=${#boards_array[@]}
5046

51-
if [ $board_count -gt 0 ]
52-
then
47+
if [ "$board_count" -gt 0 ]; then
5348
json_matrix='{"fqbn": ['
54-
for board in ${boards_array[@]}
55-
do
49+
for board in "${boards_array[@]}"; do
5650
json_matrix+='"'$board'"'
57-
if [ $board_count -gt 1 ]
58-
then
51+
if [ "$board_count" -gt 1 ]; then
5952
json_matrix+=","
6053
fi
61-
board_count=$(($board_count - 1))
54+
board_count=$((board_count - 1))
6255
done
6356
json_matrix+=']}'
6457

65-
echo $json_matrix
66-
echo "FQBNS=${json_matrix}" >> $GITHUB_ENV
58+
echo "$json_matrix"
59+
echo "FQBNS=${json_matrix}" >> "$GITHUB_ENV"
6760
else
68-
echo "FQBNS=" >> $GITHUB_ENV
69-
fi
61+
echo "FQBNS=" >> "$GITHUB_ENV"
62+
fi

‎.github/scripts/install-arduino-cli.sh

Copy file name to clipboardExpand all lines: .github/scripts/install-arduino-cli.sh
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
OSBITS=`uname -m`
3+
OSBITS=$(uname -m)
44
if [[ "$OSTYPE" == "linux"* ]]; then
55
export OS_IS_LINUX="1"
66
if [[ "$OSBITS" == "i686" ]]; then
@@ -49,4 +49,3 @@ if [ ! -d "$ARDUINO_IDE_PATH" ] || [ ! -f "$ARDUINO_IDE_PATH/arduino-cli" ]; the
4949
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR="$ARDUINO_IDE_PATH" sh
5050
fi
5151
fi
52-

‎.github/scripts/install-arduino-core-esp32.sh

Copy file name to clipboardExpand all lines: .github/scripts/install-arduino-core-esp32.sh
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
55
echo "Installing ESP32 Arduino Core ..."
66
script_init_path="$PWD"
77
mkdir -p "$ARDUINO_USR_PATH/hardware/espressif"
8-
cd "$ARDUINO_USR_PATH/hardware/espressif"
8+
cd "$ARDUINO_USR_PATH/hardware/espressif" || exit
99

1010
echo "Installing Python Serial ..."
1111
pip install pyserial > /dev/null
@@ -15,25 +15,25 @@ if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
1515
pip install requests > /dev/null
1616
fi
1717

18-
if [ ! -z "$GITHUB_REPOSITORY" ]; then
18+
if [ -n "$GITHUB_REPOSITORY" ]; then
1919
echo "Linking Core..."
20-
ln -s $GITHUB_WORKSPACE esp32
20+
ln -s "$GITHUB_WORKSPACE" esp32
2121
else
2222
echo "Cloning Core Repository..."
2323
git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1
2424
fi
2525

2626
#echo "Updating Submodules ..."
27-
cd esp32
27+
cd esp32 || exit
2828
#git submodule update --init --recursive > /dev/null 2>&1
2929

3030
echo "Installing Platform Tools ..."
3131
if [ "$OS_IS_WINDOWS" == "1" ]; then
32-
cd tools && ./get.exe
32+
cd tools && ./get.exe
3333
else
34-
cd tools && python get.py
34+
cd tools && python get.py
3535
fi
36-
cd $script_init_path
36+
cd "$script_init_path" || exit
3737

3838
echo "ESP32 Arduino has been installed in '$ARDUINO_ESP32_PATH'"
3939
echo ""

‎.github/scripts/install-arduino-ide.sh

Copy file name to clipboardExpand all lines: .github/scripts/install-arduino-ide.sh
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#OSTYPE: 'msys', ARCH: 'x86_64' => win32
55
#OSTYPE: 'darwin18', ARCH: 'i386' => macos
66

7-
OSBITS=`uname -m`
7+
OSBITS=$(uname -m)
88
if [[ "$OSTYPE" == "linux"* ]]; then
99
export OS_IS_LINUX="1"
1010
ARCHIVE_FORMAT="tar.xz"
@@ -77,4 +77,3 @@ if [ ! -d "$ARDUINO_IDE_PATH" ]; then
7777
echo "Arduino IDE Installed in '$ARDUINO_IDE_PATH'"
7878
echo ""
7979
fi
80-

‎.github/scripts/install-platformio-esp32.sh

Copy file name to clipboardExpand all lines: .github/scripts/install-platformio-esp32.sh
+35-19Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ python -c "$replace_script"
5252

5353
if [ "$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"
5656
else
5757
echo "Cloning Core Repository ..."
5858
git clone --recursive https://github.com/espressif/arduino-esp32.git "$PLATFORMIO_ESP32_PATH" > /dev/null 2>&1
@@ -61,7 +61,7 @@ fi
6161
echo "PlatformIO for ESP32 has been installed"
6262
echo ""
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" --project-option="$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"/ci.json ]; 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"/ci.json)
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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.