Improved reliability of shell scripts (#699)

* Add double quotes for shell variables
* Added exit for cd command. Prevent run commands after incorrect change directory.
This commit is contained in:
rusdacent 2021-09-13 04:44:02 +03:00 committed by GitHub
parent a4dae290e2
commit 202c1d4b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 13 deletions

View File

@ -6,7 +6,7 @@ CLANG_FORMAT_BIN="/usr/bin/clang-format-12"
PROJECT_DIR=$(pwd)
cd $PROJECT_DIR
cd "$PROJECT_DIR" || exit
echo "RUN C\C++ SYNTAX CHECK"
C_FILES=$(find . \
@ -34,7 +34,7 @@ fi
read -p "Do you want fix syntax? (y/n): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
cd $PROJECT_DIR
cd "$PROJECT_DIR" || exit
# We use root in container and clang-format rewriting files. We'll need change owner to original
local_user=$(stat -c '%u' .clang-format)

View File

@ -5,8 +5,8 @@ set -x -e
SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
rm $PROJECT_DIR/bootloader/.obj/f*/flash || true
make -C $PROJECT_DIR/bootloader -j9 flash
rm "$PROJECT_DIR"/bootloader/.obj/f*/flash || true
make -C "$PROJECT_DIR"/bootloader -j9 flash
rm $PROJECT_DIR/firmware/.obj/f*/flash || true
make -C $PROJECT_DIR/firmware -j9 flash
rm "$PROJECT_DIR"/firmware/.obj/f*/flash || true
make -C "$PROJECT_DIR"/firmware -j9 flash

View File

@ -6,15 +6,15 @@ SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
COPRO_DIR="$PROJECT_DIR/lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x"
STM32_Programmer_CLI -c port=swd -fwupgrade $COPRO_DIR/stm32wb5x_FUS_fw_for_fus_0_5_3.bin 0x080EC000 || true
STM32_Programmer_CLI -c port=swd -fwupgrade "$COPRO_DIR"/stm32wb5x_FUS_fw_for_fus_0_5_3.bin 0x080EC000 || true
STM32_Programmer_CLI -c port=swd
STM32_Programmer_CLI -c port=swd -fwupgrade $COPRO_DIR/stm32wb5x_FUS_fw.bin 0x080EC000 || true
STM32_Programmer_CLI -c port=swd -fwupgrade "$COPRO_DIR"/stm32wb5x_FUS_fw.bin 0x080EC000 || true
STM32_Programmer_CLI -c port=swd
STM32_Programmer_CLI -c port=swd -fwdelete
STM32_Programmer_CLI -c port=swd -fwupgrade $COPRO_DIR/stm32wb5x_BLE_Stack_full_fw.bin 0x080CA000 firstinstall=0
STM32_Programmer_CLI -c port=swd -fwupgrade "$COPRO_DIR"/stm32wb5x_BLE_Stack_full_fw.bin 0x080CA000 firstinstall=0
STM32_Programmer_CLI -c port=swd -ob nSWBOOT0=1 nBOOT0=1

View File

@ -7,11 +7,11 @@ if [ "$#" -ne 1 ]; then
exit
fi
if [ ! -f $1 ]; then
if [ ! -f "$1" ]; then
echo "Unable to open OTP file"
exit
fi
STM32_Programmer_CLI -c port=usb1 -d $1 0x1FFF7000
STM32_Programmer_CLI -c port=usb1 -d "$1" 0x1FFF7000
STM32_Programmer_CLI -c port=usb1 -r8 0x1FFF7000 8

View File

@ -7,11 +7,11 @@ if [ "$#" -ne 1 ]; then
exit
fi
if [ ! -f $1 ]; then
if [ ! -f "$1" ]; then
echo "Unable to open OTP file"
exit
fi
STM32_Programmer_CLI -c port=swd -d $1 0x1FFF7000
STM32_Programmer_CLI -c port=swd -d "$1" 0x1FFF7000
STM32_Programmer_CLI -c port=swd -r8 0x1FFF7000 8