From 78de3202c4229810299157a7b605213f2841ca2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 27 Jul 2023 14:09:00 -0400 Subject: [PATCH] Fix: format-cpp: don't pass -i twice to clang-format MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit From Simon Marchi's original commit message: I'm trying to run format-cpp, with clang-format-14 in my PATH, and I get a ton of these messages: clang-format-14: for the -i option: may only occur zero or one times! This is because -i is present in the FORMATTER variables, as well as in the command line where the formatter is invoked. Remove the one in the command-line. Instead of assuming the FORMATTER variable contains '-i', assume it doesn't since the options are not semantically part of the formatter's name. The '-i' option is passed to the formatter invocation directly since it is always needed. Signed-off-by: Jérémie Galarneau Change-Id: I0c26ff0d8d4d99b3f161ca9e5aa94ff867e3f916 --- format-cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/format-cpp b/format-cpp index a610728f3..d7155b21d 100755 --- a/format-cpp +++ b/format-cpp @@ -46,10 +46,10 @@ if [[ -n "$FORMATTER" ]]; then formatter=$FORMATTER elif command -v clang-format-$expected_formatter_major_version &> /dev/null; then # Try using the expected version of clang-format - formatter="clang-format-$expected_formatter_major_version -i" + formatter="clang-format-$expected_formatter_major_version" else # Try using `clang-format` as is - formatter='clang-format -i' + formatter='clang-format' fi # Try to format files -- 2.34.1