From 1526b2a2eb8fd268da850f4a5c88055fba3fec22 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Thu, 14 Oct 2021 21:02:23 -0300 Subject: [PATCH] which => command -v; different format.sh exit codes `which` is a debian tool that is being deprecated in favour of posix-standard `command -v`, so which to that to avoid deprecation warnings. Change the exit codes of `contrib/format.sh verify` to be unique for each formatting program. --- contrib/format.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/format.sh b/contrib/format.sh index 28ceb65ce..956f5db92 100755 --- a/contrib/format.sh +++ b/contrib/format.sh @@ -2,12 +2,12 @@ CLANG_FORMAT_DESIRED_VERSION=11 -binary=$(which clang-format-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null) +binary=$(command -v clang-format-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null) if [ $? -ne 0 ]; then - binary=$(which clang-format-mp-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null) + binary=$(command -v clang-format-mp-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null) fi if [ $? -ne 0 ]; then - binary=$(which clang-format 2>/dev/null) + binary=$(command -v clang-format 2>/dev/null) if [ $? -ne 0 ]; then echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script." exit 1 @@ -22,18 +22,18 @@ fi cd "$(dirname $0)/../" if [ "$1" = "verify" ] ; then if [ $($binary --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|mm?)$' | grep -v '\#') | grep '' | wc -l) -ne 0 ] ; then - exit 1 + exit 2 fi else $binary -i $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|mm)$' | grep -v '\#') &> /dev/null fi -swift_format=$(which swiftformat 2>/dev/null) +swift_format=$(command -v swiftformat 2>/dev/null) if [ $? -eq 0 ]; then if [ "$1" = "verify" ] ; then for f in $(find daemon | grep -E '\.swift$' | grep -v '\#') ; do if [ $($swift_format --quiet --dryrun < "$f" | diff "$f" - | wc -l) -ne 0 ] ; then - exit 1 + exit 3 fi done else