From cc9546bb2fb1c570dcb0a618c6f002ec29e3b46a Mon Sep 17 00:00:00 2001 From: Matthias Kollmann Date: Thu, 16 Sep 2021 22:09:15 +0200 Subject: [PATCH 1/2] macOS support for run_protoc.sh --- other/tools/run_protoc.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/other/tools/run_protoc.sh b/other/tools/run_protoc.sh index 2a885b1b..d5472272 100755 --- a/other/tools/run_protoc.sh +++ b/other/tools/run_protoc.sh @@ -24,7 +24,11 @@ command -v protoc-gen-mavsdk > /dev/null || { } function snake_case_to_camel_case { - echo $1 | sed -r 's/(^|_)([a-z])/\U\2/g' + if [[ "$OSTYPE" == "darwin"* ]]; then + echo $1 | gsed -r 's/(^|_)([a-z])/\U\2/g' + else + echo $1 | sed -r 's/(^|_)([a-z])/\U\2/g' + fi } function generate { From 4fde88a88353d936728e7143c59d925c167f7efa Mon Sep 17 00:00:00 2001 From: Matthias Kollmann Date: Mon, 20 Sep 2021 13:26:52 +0200 Subject: [PATCH 2/2] switched to awk for macOS compability --- other/tools/run_protoc.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/other/tools/run_protoc.sh b/other/tools/run_protoc.sh index d5472272..ee65152a 100755 --- a/other/tools/run_protoc.sh +++ b/other/tools/run_protoc.sh @@ -24,11 +24,7 @@ command -v protoc-gen-mavsdk > /dev/null || { } function snake_case_to_camel_case { - if [[ "$OSTYPE" == "darwin"* ]]; then - echo $1 | gsed -r 's/(^|_)([a-z])/\U\2/g' - else - echo $1 | sed -r 's/(^|_)([a-z])/\U\2/g' - fi + echo $1 | awk -v FS="_" -v OFS="" '{for (i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1' } function generate {