|
9 | 9 | mkdir "example-tryout" |
10 | 10 | rsync -a ./example/ ./example-tryout/ |
11 | 11 | cd ./example-tryout |
12 | | -pwd |
13 | | -ls -lrt |
| 12 | + |
14 | 13 | # sets the locale for all commands run in the current shell session to the "C" locale, which is the default POSIX locale. This makes programs like sed and find treat files as raw bytes, ignoring any character encoding issues. It helps avoid errors like illegal byte sequence when processing files with mixed or unknown encodings. |
15 | 14 | export LC_ALL=C |
16 | 15 |
|
17 | | -find . -type f -exec sed -e s/Examples/{{cookiecutter.domain_plural_capitalized}}/g -i '' '{}' ';' |
| 16 | +# Detect OS and set sed inline flag |
| 17 | +if [[ "$(uname)" == "Darwin" ]]; then |
| 18 | + SED_INPLACE=(-i '') |
| 19 | +else |
| 20 | + SED_INPLACE=(-i) |
| 21 | +fi |
| 22 | + |
| 23 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/Examples/{{cookiecutter.domain_plural_capitalized}}/g '{}' ';' |
18 | 24 | find . -depth -name '*Examples*' -print0|while IFS= read -rd '' f; do mv -i "$f" "$(echo "$f"|sed -E 's/(.*)Examples/\1{{cookiecutter.domain_plural_capitalized}}/')"; done |
19 | | -find . -type f -exec sed -e s/examples/{{cookiecutter.domain_plural}}/g -i '' '{}' ';' |
| 25 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/examples/{{cookiecutter.domain_plural}}/g '{}' ';' |
20 | 26 | find . -depth -name '*examples*' -print0|while IFS= read -rd '' f; do mv -i "$f" "$(echo "$f"|sed -E 's/(.*)examples/\1{{cookiecutter.domain_plural}}/')"; done |
21 | | -find . -type f -exec sed -e s/Example/{{cookiecutter.domain_capitalized}}/g -i '' '{}' ';' |
| 27 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/Example/{{cookiecutter.domain_capitalized}}/g '{}' ';' |
22 | 28 | find . -depth -name '*Example*' -print0|while IFS= read -rd '' f; do mv -i "$f" "$(echo "$f"|sed -E 's/(.*)Example/\1{{cookiecutter.domain_capitalized}}/')"; done |
23 | | -find . -type f -exec sed -e s/example/{{cookiecutter.domain}}/g -i '' '{}' ';' |
| 29 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/example/{{cookiecutter.domain}}/g '{}' ';' |
24 | 30 | find . -depth -name '*example*' -print0|while IFS= read -rd '' f; do mv -i "$f" "$(echo "$f"|sed -E 's/(.*)example/\1{{cookiecutter.domain}}/')"; done |
25 | | -find . -type f -exec sed -e s/packagename/{{cookiecutter.package_name}}/g -i '' '{}' ';' |
| 31 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/packagename/{{cookiecutter.package_name}}/g '{}' ';' |
26 | 32 | find . -depth -name '*packagename*' -print0|while IFS= read -rd '' f; do mv -i "$f" "$(echo "$f"|sed -E 's/(.*)packagename/\1{{cookiecutter.package_name}}/')"; done |
27 | | -find . -type f -exec sed -e s/artifactName/{{cookiecutter.artifact_id}}/g -i '' '{}' ';' |
28 | | -find . -type f -exec sed -e s/group-id/{{cookiecutter.group_id}}/g -i '' '{}' ';' |
| 33 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/artifactName/{{cookiecutter.artifact_id}}/g '{}' ';' |
| 34 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/group-id/{{cookiecutter.group_id}}/g '{}' ';' |
29 | 35 | ## For the following, we need to replace EXAMPLES and EXAMPLE with the domain name |
30 | | -find . -type f -exec sed -e s/EXAMPLES/{{cookiecutter.domain_plural_uppercase}}/g -i '' '{}' ';' |
31 | | -find . -type f -exec sed -e s/EXAMPLE/{{cookiecutter.domain_uppercase}}/g -i '' '{}' ';' |
| 36 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/EXAMPLES/{{cookiecutter.domain_plural_uppercase}}/g '{}' ';' |
| 37 | +find . -type f -exec sed "${SED_INPLACE[@]}" -e s/EXAMPLE/{{cookiecutter.domain_uppercase}}/g '{}' ';' |
0 commit comments