Skip to content
Snippets Groups Projects
Commit bee18358 authored by Matthias Grob's avatar Matthias Grob Committed by Daniel Agar
Browse files

Tools: fix style consistency in shell scripts "if [...]; then"

parent c21849b9
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ else ...@@ -25,7 +25,7 @@ else
if [ "$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_1" -a \ if [ "$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_1" -a \
"$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_2" -a \ "$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_2" -a \
"$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_3" -a \ "$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_3" -a \
"$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_4" ]; "$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_4" ]
then then
echo "Error: you're using ${ASTYLE_VER}" echo "Error: you're using ${ASTYLE_VER}"
echo "but should be using ${ASTYLE_VER_REQUIRED_1}, ${ASTYLE_VER_REQUIRED_2}, ${ASTYLE_VER_REQUIRED_3}, or ${ASTYLE_VER_REQUIRED_4} instead" echo "but should be using ${ASTYLE_VER_REQUIRED_1}, ${ASTYLE_VER_REQUIRED_2}, ${ASTYLE_VER_REQUIRED_3}, or ${ASTYLE_VER_REQUIRED_4} instead"
...@@ -36,8 +36,7 @@ fi ...@@ -36,8 +36,7 @@ fi
CI="${CI:-false}" CI="${CI:-false}"
DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
if [[ "$@" == "--fix" ]] if [[ "$@" == "--fix" ]]; then
then
export PX4_ASTYLE_FIX=1 export PX4_ASTYLE_FIX=1
fi fi
......
...@@ -3,8 +3,7 @@ set -eu ...@@ -3,8 +3,7 @@ set -eu
PATTERN="-e ." PATTERN="-e ."
if [ $# -gt 0 ] if [ $# -gt 0 ]; then
then
PATTERN="$1" PATTERN="$1"
fi fi
......
...@@ -48,8 +48,7 @@ fi ...@@ -48,8 +48,7 @@ fi
# If there are whitespace errors, print the offending file names and fail. # If there are whitespace errors, print the offending file names and fail.
git diff-index --check --cached $against -- git diff-index --check --cached $against --
if [ $? -ne 0 ] if [ $? -ne 0 ]; then
then
exit 1 exit 1
fi fi
......
...@@ -3,12 +3,10 @@ ...@@ -3,12 +3,10 @@
function check_git_submodule { function check_git_submodule {
# The .git exists in a submodule if init and update have been done. # The .git exists in a submodule if init and update have been done.
if [[ -f $1"/.git" || -d $1"/.git" ]]; if [[ -f $1"/.git" || -d $1"/.git" ]]; then
then
# CI environment always update # CI environment always update
if [ "$CI" == "true" ]; if [ "$CI" == "true" ]; then
then
git submodule --quiet sync --recursive -- $1 git submodule --quiet sync --recursive -- $1
git submodule --quiet update --init --recursive -- $1 || true git submodule --quiet update --init --recursive -- $1 || true
git submodule --quiet update --init --recursive -- $1 git submodule --quiet update --init --recursive -- $1
...@@ -17,8 +15,7 @@ then ...@@ -17,8 +15,7 @@ then
SUBMODULE_STATUS=$(git submodule summary "$1") SUBMODULE_STATUS=$(git submodule summary "$1")
STATUSRETVAL=$(echo $SUBMODULE_STATUS | grep -A20 -i "$1") STATUSRETVAL=$(echo $SUBMODULE_STATUS | grep -A20 -i "$1")
if ! [[ -z "$STATUSRETVAL" ]]; if ! [[ -z "$STATUSRETVAL" ]]; then
then
echo -e "\033[31mChecked $1 submodule, ACTION REQUIRED:\033[0m" echo -e "\033[31mChecked $1 submodule, ACTION REQUIRED:\033[0m"
echo "" echo ""
echo -e "Different commits:" echo -e "Different commits:"
...@@ -39,11 +36,9 @@ then ...@@ -39,11 +36,9 @@ then
echo -e " Use \033[94mgit add $1 && git commit -m 'Updated $1'\033[0m to choose this version (careful!)" echo -e " Use \033[94mgit add $1 && git commit -m 'Updated $1'\033[0m to choose this version (careful!)"
echo "" echo ""
read user_cmd read user_cmd
if [ "$user_cmd" == "y" ] if [ "$user_cmd" == "y" ]; then
then
echo "Continuing build with manually overridden submodule.." echo "Continuing build with manually overridden submodule.."
elif [ "$user_cmd" == "u" ] elif [ "$user_cmd" == "u" ]; then
then
git submodule sync --recursive -- $1 git submodule sync --recursive -- $1
git submodule update --init --recursive -- $1 || true git submodule update --init --recursive -- $1 || true
git submodule update --init --recursive --force -- $1 git submodule update --init --recursive --force -- $1
...@@ -62,8 +57,7 @@ fi ...@@ -62,8 +57,7 @@ fi
} }
# If called with a path then respect $GIT_SUBMODULES_ARE_EVIL but do normal processing # If called with a path then respect $GIT_SUBMODULES_ARE_EVIL but do normal processing
if [ "$#" != "0" ]; if [ "$#" != "0" ]; then
then
# called with a path then process only that path but respect $GIT_SUBMODULES_ARE_EVIL # called with a path then process only that path but respect $GIT_SUBMODULES_ARE_EVIL
[ -n "$GIT_SUBMODULES_ARE_EVIL" ] && { [ -n "$GIT_SUBMODULES_ARE_EVIL" ] && {
# GIT_SUBMODULES_ARE_EVIL is set, meaning user doesn't want submodules updated # GIT_SUBMODULES_ARE_EVIL is set, meaning user doesn't want submodules updated
......
...@@ -12,8 +12,7 @@ set i {{ command.instance }} ...@@ -12,8 +12,7 @@ set i {{ command.instance }}
{% endif -%} {% endif -%}
# get the device & baudrate # get the device & baudrate
sh $PRT_F sh $PRT_F
if [ $SERIAL_DEV != none ] if [ $SERIAL_DEV != none ]; then
then
{% if not constrained_flash -%} {% if not constrained_flash -%}
echo "Starting {{ command.label }} on $SERIAL_DEV" echo "Starting {{ command.label }} on $SERIAL_DEV"
{% endif -%} {% endif -%}
......
...@@ -4,10 +4,8 @@ ...@@ -4,10 +4,8 @@
set SERIAL_DEV none set SERIAL_DEV none
{% for serial_device in serial_devices -%} {% for serial_device in serial_devices -%}
if param compare "$PRT" {{ serial_device.index }} if param compare "$PRT" {{ serial_device.index }}; then
then if [ "x$PRT_{{ serial_device.tag }}_" = "x" ]; then
if [ "x$PRT_{{ serial_device.tag }}_" = "x" ]
then
set SERIAL_DEV {{ serial_device.device }} set SERIAL_DEV {{ serial_device.device }}
set BAUD_PARAM SER_{{ serial_device.tag }}_BAUD set BAUD_PARAM SER_{{ serial_device.tag }}_BAUD
set PRT_{{ serial_device.tag }}_ 1 set PRT_{{ serial_device.tag }}_ 1
......
...@@ -23,15 +23,12 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) ...@@ -23,15 +23,12 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# otherwise warn and point to docker? # otherwise warn and point to docker?
UBUNTU_RELEASE=`lsb_release -rs` UBUNTU_RELEASE=`lsb_release -rs`
if [[ "${UBUNTU_RELEASE}" == "14.04" ]] if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then
then
echo "Ubuntu 14.04 unsupported, see docker px4io/px4-dev-base" echo "Ubuntu 14.04 unsupported, see docker px4io/px4-dev-base"
exit 1 exit 1
elif [[ "${UBUNTU_RELEASE}" == "16.04" ]] elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
then
echo "Ubuntu 16.04" echo "Ubuntu 16.04"
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]] elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
then
echo "Ubuntu 18.04" echo "Ubuntu 18.04"
fi fi
......
...@@ -31,20 +31,17 @@ fi ...@@ -31,20 +31,17 @@ fi
if [ "$model" != none ]; then if [ "$model" != none ]; then
jmavsim_pid=`ps aux | grep java | grep "\-jar jmavsim_run.jar" | awk '{ print $2 }'` jmavsim_pid=`ps aux | grep java | grep "\-jar jmavsim_run.jar" | awk '{ print $2 }'`
if [ -n "$jmavsim_pid" ] if [ -n "$jmavsim_pid" ]; then
then
kill $jmavsim_pid kill $jmavsim_pid
fi fi
fi fi
if [ "$model" == "" ] || [ "$model" == "none" ] if [ "$model" == "" ] || [ "$model" == "none" ]; then
then
echo "empty model, setting iris as default" echo "empty model, setting iris as default"
model="iris" model="iris"
fi fi
if [ "$#" -lt 6 ] if [ "$#" -lt 6 ]; then
then
echo usage: sitl_run.sh sitl_bin debugger program model src_path build_path echo usage: sitl_run.sh sitl_bin debugger program model src_path build_path
echo "" echo ""
exit 1 exit 1
...@@ -67,24 +64,19 @@ done ...@@ -67,24 +64,19 @@ done
SIM_PID=0 SIM_PID=0
# Allow speed factor to bet set from environment. # Allow speed factor to bet set from environment.
if [[ -n "$PX4_SIM_SPEED_FACTOR" ]]; if [[ -n "$PX4_SIM_SPEED_FACTOR" ]]; then
then
speed_factor=$PX4_SIM_SPEED_FACTOR speed_factor=$PX4_SIM_SPEED_FACTOR
else else
speed_factor=1 speed_factor=1
fi fi
if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ] if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ]; then
then
# Start Java simulator # Start Java simulator
"$src_path"/Tools/jmavsim_run.sh -r 250 -f $speed_factor & "$src_path"/Tools/jmavsim_run.sh -r 250 -f $speed_factor &
SIM_PID=`echo $!` SIM_PID=`echo $!`
elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ] elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
then if [ -x "$(command -v gazebo)" ]; then
if [ -x "$(command -v gazebo)" ] if [[ -z "$DONT_RUN" ]]; then
then
if [[ -z "$DONT_RUN" ]]
then
# Set the plugin path so Gazebo finds our model and sim # Set the plugin path so Gazebo finds our model and sim
source "$src_path/Tools/setup_gazebo.bash" "${src_path}" "${build_path}" source "$src_path/Tools/setup_gazebo.bash" "${src_path}" "${build_path}"
...@@ -123,26 +115,19 @@ echo SITL COMMAND: $sitl_command ...@@ -123,26 +115,19 @@ echo SITL COMMAND: $sitl_command
export PX4_SIM_MODEL=${model} export PX4_SIM_MODEL=${model}
if [[ -n "$DONT_RUN" ]] if [[ -n "$DONT_RUN" ]]; then
then
echo "Not running simulation (\$DONT_RUN is set)." echo "Not running simulation (\$DONT_RUN is set)."
elif [ "$debugger" == "lldb" ] elif [ "$debugger" == "lldb" ]; then
then
eval lldb -- $sitl_command eval lldb -- $sitl_command
elif [ "$debugger" == "gdb" ] elif [ "$debugger" == "gdb" ]; then
then
eval gdb --args $sitl_command eval gdb --args $sitl_command
elif [ "$debugger" == "ddd" ] elif [ "$debugger" == "ddd" ]; then
then
eval ddd --debugger gdb --args $sitl_command eval ddd --debugger gdb --args $sitl_command
elif [ "$debugger" == "valgrind" ] elif [ "$debugger" == "valgrind" ]; then
then
eval valgrind --track-origins=yes --leak-check=full -v $sitl_command eval valgrind --track-origins=yes --leak-check=full -v $sitl_command
elif [ "$debugger" == "callgrind" ] elif [ "$debugger" == "callgrind" ]; then
then
eval valgrind --tool=callgrind -v $sitl_command eval valgrind --tool=callgrind -v $sitl_command
elif [ "$debugger" == "ide" ] elif [ "$debugger" == "ide" ]; then
then
echo "######################################################################" echo "######################################################################"
echo echo
echo "PX4 simulator not started, use your IDE to start PX4_${model} target." echo "PX4 simulator not started, use your IDE to start PX4_${model} target."
...@@ -156,14 +141,11 @@ fi ...@@ -156,14 +141,11 @@ fi
popd >/dev/null popd >/dev/null
if [[ -z "$DONT_RUN" ]] if [[ -z "$DONT_RUN" ]]; then
then if [ "$program" == "jmavsim" ]; then
if [ "$program" == "jmavsim" ]
then
pkill -9 -P $SIM_PID pkill -9 -P $SIM_PID
kill -9 $SIM_PID kill -9 $SIM_PID
elif [ "$program" == "gazebo" ] elif [ "$program" == "gazebo" ]; then
then
kill -9 $SIM_PID kill -9 $SIM_PID
if [[ ! -n "$HEADLESS" ]]; then if [[ ! -n "$HEADLESS" ]]; then
kill -9 $GUI_PID kill -9 $GUI_PID
......
...@@ -10,23 +10,19 @@ SYSTYPE=`uname -s` ...@@ -10,23 +10,19 @@ SYSTYPE=`uname -s`
# #
# XXX The uploader should be smarter than this. # XXX The uploader should be smarter than this.
# #
if [ $SYSTYPE = "Darwin" ]; if [ $SYSTYPE = "Darwin" ]; then
then
SERIAL_PORTS="/dev/tty.usbmodemPX*,/dev/tty.usbmodem*" SERIAL_PORTS="/dev/tty.usbmodemPX*,/dev/tty.usbmodem*"
fi fi
if [ $SYSTYPE = "Linux" ]; if [ $SYSTYPE = "Linux" ]; then
then
SERIAL_PORTS="/dev/serial/by-id/*_PX4_*,/dev/serial/by-id/usb-3D_Robotics*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*," SERIAL_PORTS="/dev/serial/by-id/*_PX4_*,/dev/serial/by-id/usb-3D_Robotics*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,"
fi fi
if [[ $SYSTYPE = *"CYGWIN"* ]]; if [[ $SYSTYPE = *"CYGWIN"* ]]; then
then
SERIAL_PORTS="/dev/ttyS*" SERIAL_PORTS="/dev/ttyS*"
fi fi
if [ $SYSTYPE = "" ]; if [ $SYSTYPE = "" ]; then
then
SERIAL_PORTS="COM32,COM31,COM30,COM29,COM28,COM27,COM26,COM25,COM24,COM23,COM22,COM21,COM20,COM19,COM18,COM17,COM16,COM15,COM14,COM13,COM12,COM11,COM10,COM9,COM8,COM7,COM6,COM5,COM4,COM3,COM2,COM1,COM0" SERIAL_PORTS="COM32,COM31,COM30,COM29,COM28,COM27,COM26,COM25,COM24,COM23,COM22,COM21,COM20,COM19,COM18,COM17,COM16,COM15,COM14,COM13,COM12,COM11,COM10,COM9,COM8,COM7,COM6,COM5,COM4,COM3,COM2,COM1,COM0"
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment