From f01dac9ba8b618ca74fdf02d275ab5df57c71721 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 8 May 2025 16:20:37 +0900 Subject: git/hooks: fix commit-msg hook so that it works with GNU sed --- githooks/commit-msg | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'githooks/commit-msg') diff --git a/githooks/commit-msg b/githooks/commit-msg index c25b0a0..df2dc8f 100755 --- a/githooks/commit-msg +++ b/githooks/commit-msg @@ -133,4 +133,10 @@ fi # Substitute '###'. # '$1' is passed by Git, the file name that holds commit message. -sed -i '' -e "s|###|${issue_number}|g" "${1}" +if sed --version >/dev/null 2>&1; then + # GNU sed: -i takes no arguments. + sed -i -e "s|###|${issue_number}|g" "$1" +else + # BSD sed: -i takes an extension of backup file. + sed -i '' -e "s|###|${issue_number}|g" "$1" +fi -- cgit v1.2.3-70-g09d2