Correctly detect when OpenOCD was not found.

This commit is contained in:
Thomas Roth 2020-12-12 18:42:42 +01:00
parent 85a118119a
commit 5d63afccb0
1 changed files with 7 additions and 7 deletions

View File

@ -1,9 +1,14 @@
#!/bin/bash
OPENOCD=${OPENOCD:-$(which openocd)}
OPENOCD_VERSION=$(${OPENOCD} -v 2> >(cut -f 4 -d\ ) |head -1)
ADAPTER=$1
if [[ -z ${OPENOCD} ]]; then
echo "Cannot find 'openocd' in the PATH. You can set the environment variable 'OPENOCD' to manually specify the location"
exit 2
fi
OPENOCD_VERSION=$(${OPENOCD} -v 2> >(cut -f 4 -d\\ ) |head -1)
ADAPTER=$1
mkdir -p logs backups
@ -11,8 +16,3 @@ if [[ $# -ne 1 ]] && [[ ! "$0" =~ .*"config.sh" ]]; then
echo "Usage: $0 <Adapter: jlink or stlink>"
exit 1
fi
if [[ -z ${OPENOCD} ]]; then
echo "Cannot find 'openocd' in the PATH. You can set the environment variable 'OPENOCD' to manually specify the location"
exit 2
fi