Check sed version instead of OS, dedupe sed script
This commit is contained in:
parent
769f4ddd5d
commit
a5fa7e4205
1 changed files with 11 additions and 15 deletions
|
@ -45,21 +45,17 @@ cp -r template_module "$module_dir"
|
|||
cd "$module_dir"
|
||||
|
||||
# Fill in the blanks in the template
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
sed -i '' -e "
|
||||
s/{YEAR}/$(date +%Y)/
|
||||
s%{AUTHOR}%$author%
|
||||
s%{MODULE_NAME}%$module_name%
|
||||
s%{MODULE}%$module%
|
||||
" $(find . -type f)
|
||||
else
|
||||
sed -i "
|
||||
s/{YEAR}/$(date +%Y)/
|
||||
s%{AUTHOR}%$author%
|
||||
s%{MODULE_NAME}%$module_name%
|
||||
s%{MODULE}%$module%
|
||||
" $(find -type f)
|
||||
fi
|
||||
sed_script="
|
||||
s/{YEAR}/$(date +%Y)/
|
||||
s%{AUTHOR}%$author%
|
||||
s%{MODULE_NAME}%$module_name%
|
||||
s%{MODULE}%$module%"
|
||||
case "$(sed --help 2>&1)" in
|
||||
# GNU sed wants `-i` and BSD sed wants `-i ''`
|
||||
*GNU*) sed -i -e "$sed_script" $(find . -type f); ;;
|
||||
*) sed -i '' -e "$sed_script" $(find . -type f); ;;
|
||||
esac
|
||||
|
||||
# Arduino IDE requires .ino sketches to have the same name as their directory
|
||||
mv main.ino "$module.ino"
|
||||
|
||||
|
|
Loading…
Reference in a new issue