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:
parent
a4dae290e2
commit
202c1d4b0e
@ -6,7 +6,7 @@ CLANG_FORMAT_BIN="/usr/bin/clang-format-12"
|
|||||||
|
|
||||||
PROJECT_DIR=$(pwd)
|
PROJECT_DIR=$(pwd)
|
||||||
|
|
||||||
cd $PROJECT_DIR
|
cd "$PROJECT_DIR" || exit
|
||||||
|
|
||||||
echo "RUN C\C++ SYNTAX CHECK"
|
echo "RUN C\C++ SYNTAX CHECK"
|
||||||
C_FILES=$(find . \
|
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
|
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
|
# We use root in container and clang-format rewriting files. We'll need change owner to original
|
||||||
local_user=$(stat -c '%u' .clang-format)
|
local_user=$(stat -c '%u' .clang-format)
|
||||||
|
@ -5,8 +5,8 @@ set -x -e
|
|||||||
SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
rm $PROJECT_DIR/bootloader/.obj/f*/flash || true
|
rm "$PROJECT_DIR"/bootloader/.obj/f*/flash || true
|
||||||
make -C $PROJECT_DIR/bootloader -j9 flash
|
make -C "$PROJECT_DIR"/bootloader -j9 flash
|
||||||
|
|
||||||
rm $PROJECT_DIR/firmware/.obj/f*/flash || true
|
rm "$PROJECT_DIR"/firmware/.obj/f*/flash || true
|
||||||
make -C $PROJECT_DIR/firmware -j9 flash
|
make -C "$PROJECT_DIR"/firmware -j9 flash
|
||||||
|
@ -6,15 +6,15 @@ SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
|||||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
COPRO_DIR="$PROJECT_DIR/lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x"
|
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
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
STM32_Programmer_CLI -c port=swd -fwdelete
|
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
|
STM32_Programmer_CLI -c port=swd -ob nSWBOOT0=1 nBOOT0=1
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ if [ "$#" -ne 1 ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f $1 ]; then
|
if [ ! -f "$1" ]; then
|
||||||
echo "Unable to open OTP file"
|
echo "Unable to open OTP file"
|
||||||
exit
|
exit
|
||||||
fi
|
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
|
STM32_Programmer_CLI -c port=usb1 -r8 0x1FFF7000 8
|
||||||
|
@ -7,11 +7,11 @@ if [ "$#" -ne 1 ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f $1 ]; then
|
if [ ! -f "$1" ]; then
|
||||||
echo "Unable to open OTP file"
|
echo "Unable to open OTP file"
|
||||||
exit
|
exit
|
||||||
fi
|
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
|
STM32_Programmer_CLI -c port=swd -r8 0x1FFF7000 8
|
||||||
|
Loading…
Reference in New Issue
Block a user