mirror of
https://gitea.com/gitea/docs.git
synced 2026-09-17 19:55:34 +00:00
fix sed for MacOS (#36)
Close #4 Right now on MacOS, sed will produce backup files, because on Mac, If do something like below using bash script ``` $SED_INPLACE '1s/---/---\nisOutdated: true/' $file ``` It will become the following on executed, and a backup file will be produced: ``` sed -i ''\'''\''' '1s/---/---\nisOutdated: true/' ./docs/content/doc/help/faq.zh-cn.md ``` The way to fix this in this PR is to change the `SED_INPLACE` to a function. [Reference](https://github.com/pingcap/tipb/blob/aa19c2d12587e66b31069f790fc371b6be565504/generate-cpp.sh#L4) (Tested on my Mac and backup files with suffix '' will not be produced after changing to function) Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/36 Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: HesterG <[email protected]> Co-committed-by: HesterG <[email protected]>
This commit is contained in:
+9
-6
@@ -9,11 +9,14 @@
|
||||
|
||||
set -xe
|
||||
|
||||
if sed --version 2>/dev/null | grep -q GNU; then
|
||||
SED_INPLACE="sed -i"
|
||||
else
|
||||
SED_INPLACE="sed -i ''"
|
||||
fi
|
||||
SED_INPLACE() {
|
||||
if sed --version 2>/dev/null | grep -q GNU; then
|
||||
sed -i "$@"
|
||||
else
|
||||
sed -i '' "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
version="$1"
|
||||
locale="$2"
|
||||
cur_path=`pwd`
|
||||
@@ -31,7 +34,7 @@ for file in `find ./docs/content/doc -name "*.${locale}.md"`; do
|
||||
fi
|
||||
if [[ "$latest_commit_time_en" -gt "$latest_commit_time_locale" ]]; then
|
||||
echo "file: $file, lastest commit timestamp: $latest_commit_time_en (en ver), $latest_commit_time_locale ($locale ver)"
|
||||
$SED_INPLACE '1s/---/---\nisOutdated: true/' $file
|
||||
SED_INPLACE '1s/---/---\nisOutdated: true/' $file
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user