Skip to content

Commit 7d92d6a

Browse files
[chore] Fix make update-otel on macOS (#35587)
**Description:** When working on #35580, it seemed that `make update-otel` was not properly updating the `builder-config.yaml` files. I traced this down to the `updatehelper` script not working as intended. This turned out to be because it uses some features of the `sed` utility which do not exist on macOS, causing no updates to be made. The `\s` (whitespace) regex class is a GNU extension for `sed`; the POSIX-compatible equivalent is `[[:space:]]` ([related SO question](https://stackoverflow.com/questions/18840175/find-and-replace-with-spaces-using-sed-mac-terminal)). Moreover, on macOS, the `-i` (in-place) option requires an argument, even if empty; otherwise the `-e` following it is parsed as that argument, creating an unnecessary backup file ([related SO question](https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux)). **Testing:** I manually tested this change as part of developing the aforementioned PR; the script seems to work on macOS now. It would be good for someone to test this change on Linux to make sure nothing has broken there.
1 parent 79926f8 commit 7d92d6a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,16 @@ define updatehelper
395395
echo "Usage: updatehelper <versions.yaml> <go.mod> <builder-config.yaml>"; \
396396
exit 1; \
397397
fi
398-
grep "go\.opentelemetry\.io" $(1) | sed 's/^\s*-\s*//' | while IFS= read -r line; do \
398+
grep "go\.opentelemetry\.io" $(1) | sed 's/^[[:space:]]*-[[:space:]]*//' | while IFS= read -r line; do \
399399
if grep -qF "$$line" $(2); then \
400400
package=$$(grep -F "$$line" $(2) | head -n 1 | awk '{print $$1}'); \
401401
version=$$(grep -F "$$line" $(2) | head -n 1 | awk '{print $$2}'); \
402402
builder_package=$$(grep -F "$$package" $(3) | awk '{print $$3}'); \
403403
builder_version=$$(grep -F "$$package" $(3) | awk '{print $$4}'); \
404404
if [ "$$builder_package" == "$$package" ]; then \
405-
echo "$$builder_version";\
406-
sed -i -e "s|$$builder_package.*$$builder_version|$$builder_package $$version|" $(3); \
407-
echo "[$(3)]: $$package updated to $$version"; \
405+
sed -i.bak -e "s|$$builder_package.*$$builder_version|$$builder_package $$version|" $(3); \
406+
rm $(3).bak; \
407+
echo "[$(3)]: $$package updated from $$builder_version to $$version"; \
408408
fi; \
409409
fi; \
410410
done

0 commit comments

Comments
 (0)