Skip to content

Commit

Permalink
In add_license.sh, use grep -F for the beacon
Browse files Browse the repository at this point in the history
`grep -F` prevents interpreting the given string as an expression
(treating `*`, `?` specially), which was necessary in the
`add_license.sh` because the beacon contains multiple `*`s and `<`.
  • Loading branch information
Thomas Grützmacher committed Mar 27, 2019
1 parent 47a7537 commit e7dca08
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dev_tools/scripts/add_license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ find "${GINKGO_ROOT_DIR}" \
-type f -print \
| \
while IFS='' read -r i; do
if ! grep -q "${GINKGO_LICENSE_BEACON}" "${i}"
# `grep -F` is important here because the characters in the beacon should be matched against
# and not interpreted as an expression.
if ! grep -F -q -e "${GINKGO_LICENSE_BEACON}" "${i}"
then
cat "${COMMENTED_LICENSE_FILE}" "${i}" >"${i}.new" && mv "${i}.new" "${i}"
else
beginning=$(grep -n "/\*${GINKGO_LICENSE_BEACON}" "${i}" | cut -d":" -f1)
end=$(grep -n "${GINKGO_LICENSE_BEACON}.*/" "${i}" | cut -d":" -f1)
beginning=$(grep -F -n -e "/*${GINKGO_LICENSE_BEACON}" "${i}" | cut -d":" -f1)
end=$(grep -F -n -e "${GINKGO_LICENSE_BEACON}*/" "${i}" | cut -d":" -f1)
end=$((end+1))
diff -u <(sed -n "${beginning},${end}p" "${i}") "${COMMENTED_LICENSE_FILE}" > "${DIFF_FILE}"
if [ "$(cat "${DIFF_FILE}")" != "" ]
Expand Down

0 comments on commit e7dca08

Please sign in to comment.