From cce42f7de6bdc406f40a0a16ad15285adc4a4c62 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 18 May 2020 11:54:08 +0200 Subject: Apply dirname to the first word of CXX ...in case it contains addtional arguments like -fsized-deallocation besides the compiler's pathname, which would have caused failures like basename: extra operand '-fsized-deallocation' Try 'basename --help' for more information. dirname: missing operand Try 'dirname --help' for more information. dirname: missing operand Try 'dirname --help' for more information. (printf reuses the format operand to satisfy all argument operands, so that \n | head hack is needed to get just the first one, assuming that CXX did not contain any carefully crafted escape sequences inside that first argument that would expand to a newline when printing. Also, this does not cater for leading var=value or (even more far-fetched) redirection words in CXX, but the original code did not, either.) Change-Id: Iae4d1a0ae3b67cc5e8c7a8a36258230f8ab8fd70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94406 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1d531f32edec..6e5e18021a3c 100644 --- a/configure.ac +++ b/configure.ac @@ -7205,7 +7205,7 @@ if test "$COM_IS_CLANG" = "TRUE"; then dnl The prefix where Clang resides, override to where Clang resides if dnl using a source build: if test -z "$CLANGDIR"; then - CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $CXX)))) + CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $(printf '%s\n' $CXX | head -n 1))))) fi # Assume Clang is self-built, but allow overriding COMPILER_PLUGINS_CXX to the compiler Clang was built with. if test -z "$COMPILER_PLUGINS_CXX"; then -- cgit v1.2.3