message: tools: require clang-format 9 for style check
  We need to consolidate to the most recent version, otherwise there are
  annoying effects when switching back and forth. Luckily we can install
  clang-format-9 in Ubuntu 18.04.
diff: # This script runs clang-format over all files ending in .h, .c, .cpp listed
  # by git in the given directory.
  -# Check for the clang-format version
  -version_required_major="6"
  -
  -clang_format_version() {
  - echo "At least ${version_required} is required"
  -}
  -
  -# check if clang-format is installed
  -condition=$(which clang-format 2>/dev/null | grep -v "not found" | wc -l)
  -if [ $condition -eq 0 ]; then
  - echo "clang-format is not installed"
  - clang_format_version
  - exit 1
  +version_required_major="9"
  +
  +# Try to find the latest version of clang
  +if command -v clang-format-9 >/dev/null; then
  + clang_format=clang-format-9
  +elif command -v clang-format-8 >/dev/null; then
  + clang_format=clang-format-8
  +elif command -v clang-format-7 >/dev/null; then
  + clang_format=clang-format-7
  +elif command -v clang-format >/dev/null; then
  + clang_format=clang-format
  else
  + echo "clang-format not found"
  + echo "--> check: https://mavsdk.mavlink.io/develop/en/contributing/code_style.html#formatting-and-white-space"
  + exit 1
  +fi
  - version=$(clang-format --version)
  +# Check version of found clang
  +version=$($clang_format --version)
  semver_regex="(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)"
  if [[ $version =~ $semver_regex ]]; then
  version_major=${BASH_REMATCH[1]}
  @@ -31,7 +34,6 @@ else
  echo "Could not determine clang-format version"
  exit 1
  fi
  -fi
  # Check that exactly one directory is given
  if [ $# -eq 0 ];
  @@ -65,7 +67,6 @@ fi
  cd $1 > /dev/null
  # Go through all .h, c., and .cpp files listed by git
  -# TODO: add -r argument to include all files
  files=`git ls-files | grep -E "\.h$|\.c$|\.cpp$|\.proto"`
  while IFS= read file; do
  @@ -88,7 +89,7 @@ while IFS= read file; do
  fi
  cp $file $file.orig
  - result=`clang-format -style=file -i $file`
  + result=`$clang_format -style=file -i $file`
  if ! cmp $file $file.orig >/dev/null 2>&1; then
  echo "Changed $file:"
  