diff options
author | Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2022-05-10 09:15:49 +0100 |
---|---|---|
committer | Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2022-05-10 09:15:49 +0100 |
commit | e1ce82070087fdbb93411e12732d5dd72d97722e (patch) | |
tree | ed7311e6bbac9847209e00e6946fbe6cbd87ce4d | |
parent | b6c8b20c1047006f148a9376046e45e8f036b3bd (diff) | |
download | extra-cmake-modules-e1ce82070087fdbb93411e12732d5dd72d97722e.tar.gz extra-cmake-modules-e1ce82070087fdbb93411e12732d5dd72d97722e.tar.bz2 |
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.
-rw-r--r-- | kde-modules/KDEGitCommitHooks.cmake | 8 |
1 files changed, 4 insertions, 4 deletions
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() |