From e1ce82070087fdbb93411e12732d5dd72d97722e Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Tue, 10 May 2022 09:15:49 +0100 Subject: KDEGitCommitHooks: Fix quoting of variables I was getting CMake errors in repositories that had a pre-existing commit hook: `string sub-command FIND requires 3 or 4 parameters.` Adding quotes around the variables from 6224e7b8c28d434b81a19ac47b88cb58fee9d7d5 fixes this issue for me. --- kde-modules/KDEGitCommitHooks.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'kde-modules') diff --git a/kde-modules/KDEGitCommitHooks.cmake b/kde-modules/KDEGitCommitHooks.cmake index a9ee76e9..c545352d 100644 --- a/kde-modules/KDEGitCommitHooks.cmake +++ b/kde-modules/KDEGitCommitHooks.cmake @@ -89,17 +89,17 @@ function(KDE_CONFIGURE_GIT_PRE_COMMIT_HOOK) # For when CLANG_FORMAT_SCRIPT didn't have the 'git rev-parse --git-common-dir' part set(_old_cmd "./.git/hooks/scripts/clang-format.sh") - string(FIND ${_contents} ${_old_cmd} _idx) + string(FIND "${_contents}" "${_old_cmd}" _idx) if (${_idx} GREATER -1) string(REPLACE "${_old_cmd}" "${CLANG_FORMAT_SCRIPT}" _contents "${_contents}") - file(WRITE ${_hook_file} ${_contents}) + file(WRITE ${_hook_file} "${_contents}") return() endif() - string(FIND ${_contents} ${CLANG_FORMAT_SCRIPT} _idx) + string(FIND "${_contents}" "${CLANG_FORMAT_SCRIPT}" _idx) # File exists and doesn't have the clang-format.sh line, append it # so as to not overwrite users' customisations if (_idx EQUAL -1) - file(APPEND ${_hook_file} ${CLANG_FORMAT_SCRIPT}) + file(APPEND ${_hook_file} "${CLANG_FORMAT_SCRIPT}") endif() endfunction() -- cgit v1.2.1