Skip to content

Commit

Permalink
favour using gsed over sed
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Oct 29, 2023
1 parent 4ee87c3 commit 4d7a6d3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions services/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

pushd "$SCRIPT_DIR" || exit 1

SED="sed"
if command -v gsed; then
SED="gsed"
fi

execute_template() {
input_file="$1"

sed \
"$SED" \
-e "s|\\\$NAME|${NAME:-}|g" \
-e "s|\\\$LOG_NAME|${NAME:-}|g" \
-e "s|\\\$COMMAND_ARGS|${COMMAND_ARGS:-}|g" \
Expand All @@ -22,7 +27,7 @@ execute_template() {
execute_template_inplace() {
input_file="$1"

sed -i \
"$SED" -i \
-e "s|\\\$NAME|${NAME:-}|g" \
-e "s|\\\$LOG_NAME|${NAME:-}|g" \
-e "s|\\\$COMMAND_ARGS|${COMMAND_ARGS:-}|g" \
Expand Down

0 comments on commit 4d7a6d3

Please sign in to comment.