Skip to content

Commit

Permalink
Fix overly match-happy sed commands
Browse files Browse the repository at this point in the history
We saw in cisagov/postfix-docker#47 that the sed commands in the
bump_version.sh script could inadvertently match the CC0 version in
the README.md file.  This change escapes the periods in the version
before passing it on to sed so that they only match periods and not
just any character.

Co-authored-by: Shane Frasier <[email protected]>
  • Loading branch information
mcdonnnj and jsf9k committed Sep 26, 2024
1 parent a2f3c99 commit 499eedf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bump-version
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ END_OF_LINE
)

old_version=$(< "$VERSION_FILE")
# Comment out periods so they are interpreted as periods and don't
# just match any character
old_version_regex=${old_version//\./\\\.}
new_version="$old_version"

bump_part=""
Expand Down Expand Up @@ -143,9 +146,9 @@ if [ "$with_prerelease" = true ]; then
fi

tmp_file=/tmp/version.$$
sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file
sed "s/$old_version_regex/$new_version/" $VERSION_FILE > $tmp_file
mv $tmp_file $VERSION_FILE
sed "s/$old_version/$new_version/" $README_FILE > $tmp_file
sed "s/$old_version_regex/$new_version/" $README_FILE > $tmp_file
mv $tmp_file $README_FILE
git add $VERSION_FILE $README_FILE
git commit --message "$commit_prefix version from $old_version to $new_version"
Expand Down

0 comments on commit 499eedf

Please sign in to comment.