From cd7b7887fa1639848b76a3c39084ec41e78e278a Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 21 Jun 2023 14:10:15 -0400 Subject: [PATCH 1/7] Make bootstrap.sh more friendly to other shells. I found some CI systems trying to use dash, and that does not seem to work at all due to it not understanding '<<<' or `[[`. Dash is still not ok because overall because arguments to `.` do not get passed along, however it would work as a default. Changes: - loop using IFS (and set sh_word_split for ZSH) - replaced `[[` tests with `[` --- scripts/setup/bootstrap.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/setup/bootstrap.sh b/scripts/setup/bootstrap.sh index 925183b9e3f353..84b06884cb71b6 100644 --- a/scripts/setup/bootstrap.sh +++ b/scripts/setup/bootstrap.sh @@ -19,9 +19,9 @@ _install_additional_pip_requirements() { shift # figure out additional pip install items - while [[ $# -gt 0 ]]; do + while [ $# -gt 0 ]; do case $1 in - -p | --platform) + -p|--platform) _SETUP_PLATFORM=$2 shift # argument shift # value @@ -32,13 +32,14 @@ _install_additional_pip_requirements() { esac done - if ! [ -z "$_SETUP_PLATFORM" ]; then + if [ -n "$_SETUP_PLATFORM" ]; then + _OLD_IFS=$IFS + IFS="," if [ -n "$ZSH_VERSION" ]; then - IFS="," read -r -A _PLATFORMS <<<"$_SETUP_PLATFORM" - else - IFS="," read -r -a _PLATFORMS <<<"$_SETUP_PLATFORM" + setopt sh_word_split fi - for platform in "${_PLATFORMS[@]}"; do + + for platform in ${_SETUP_PLATFORM}; do # Allow none as an alias of nothing extra installed (like -p none) if [ "$platform" != "none" ]; then echo "Installing pip requirements for $platform..." @@ -47,6 +48,8 @@ _install_additional_pip_requirements() { -c "$_CHIP_ROOT/scripts/setup/constraints.txt" fi done + IFS=$_OLD_IFS + unset _OLD_IFS unset _PLATFORMS fi From 321b2d39819a6b3de86eca4fa7f7429cd6bb94a2 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 21 Jun 2023 14:14:17 -0400 Subject: [PATCH 2/7] Restyle --- scripts/setup/bootstrap.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/setup/bootstrap.sh b/scripts/setup/bootstrap.sh index 84b06884cb71b6..a79b8d5061c292 100644 --- a/scripts/setup/bootstrap.sh +++ b/scripts/setup/bootstrap.sh @@ -21,7 +21,7 @@ _install_additional_pip_requirements() { # figure out additional pip install items while [ $# -gt 0 ]; do case $1 in - -p|--platform) + -p | --platform) _SETUP_PLATFORM=$2 shift # argument shift # value @@ -36,10 +36,10 @@ _install_additional_pip_requirements() { _OLD_IFS=$IFS IFS="," if [ -n "$ZSH_VERSION" ]; then - setopt sh_word_split + setopt sh_word_split fi - for platform in ${_SETUP_PLATFORM}; do + for platform in "$_SETUP_PLATFORM"; do # Allow none as an alias of nothing extra installed (like -p none) if [ "$platform" != "none" ]; then echo "Installing pip requirements for $platform..." From 74e5e0408fb37ab29282a44f9b71fcac0883df13 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 21 Jun 2023 14:15:13 -0400 Subject: [PATCH 3/7] Remove quoting logic that breaks execution --- scripts/setup/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup/bootstrap.sh b/scripts/setup/bootstrap.sh index a79b8d5061c292..8fa9b6c8be6d82 100644 --- a/scripts/setup/bootstrap.sh +++ b/scripts/setup/bootstrap.sh @@ -39,7 +39,7 @@ _install_additional_pip_requirements() { setopt sh_word_split fi - for platform in "$_SETUP_PLATFORM"; do + for platform in ${_SETUP_PLATFORM}; do # Allow none as an alias of nothing extra installed (like -p none) if [ "$platform" != "none" ]; then echo "Installing pip requirements for $platform..." From efbfaa4eaee86a9c45c05c37e9b3b9297ba6140d Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 21 Jun 2023 14:17:06 -0400 Subject: [PATCH 4/7] Stop restyling bootstrap.sh --- .restyled.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.restyled.yaml b/.restyled.yaml index a57f9ce75a838a..c920ab61ab1348 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -80,6 +80,7 @@ exclude: - "zzz_generated/**/*" # already clang-formatted by our zap tooling - "src/controller/java/generated/java/**/*" # not formatted: generated files - "src/controller/java/zap-generated/**/*" # not formatted: generated files + - "scripts/bootstrap.sh" # tries to quote loop variable changed_paths: From cb6f86cb681da4d5f895dbe88d0f5453b4446031 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 21 Jun 2023 14:18:02 -0400 Subject: [PATCH 5/7] Fix path --- .restyled.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.restyled.yaml b/.restyled.yaml index c920ab61ab1348..32a77fee6fe5f9 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -80,7 +80,7 @@ exclude: - "zzz_generated/**/*" # already clang-formatted by our zap tooling - "src/controller/java/generated/java/**/*" # not formatted: generated files - "src/controller/java/zap-generated/**/*" # not formatted: generated files - - "scripts/bootstrap.sh" # tries to quote loop variable + - "scripts/setup/bootstrap.sh" # tries to quote loop variable changed_paths: From 61952929009fc3cac26f540523fcf58e90af4415 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 21 Jun 2023 14:47:48 -0400 Subject: [PATCH 6/7] Do not permanently alter zsh options, use local_options --- scripts/setup/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup/bootstrap.sh b/scripts/setup/bootstrap.sh index 8fa9b6c8be6d82..1f7cbf89b52579 100644 --- a/scripts/setup/bootstrap.sh +++ b/scripts/setup/bootstrap.sh @@ -36,7 +36,7 @@ _install_additional_pip_requirements() { _OLD_IFS=$IFS IFS="," if [ -n "$ZSH_VERSION" ]; then - setopt sh_word_split + setopt local_options sh_word_split fi for platform in ${_SETUP_PLATFORM}; do From c4f833935e34c575c9a73d8ca73489af64a76521 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 21 Jun 2023 15:33:06 -0400 Subject: [PATCH 7/7] update sh_word_split to shwordsplit. Both seem to work, the non-underscore seems more common in docs --- scripts/setup/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup/bootstrap.sh b/scripts/setup/bootstrap.sh index 1f7cbf89b52579..2fea8adc8f702d 100644 --- a/scripts/setup/bootstrap.sh +++ b/scripts/setup/bootstrap.sh @@ -36,7 +36,7 @@ _install_additional_pip_requirements() { _OLD_IFS=$IFS IFS="," if [ -n "$ZSH_VERSION" ]; then - setopt local_options sh_word_split + setopt local_options shwordsplit fi for platform in ${_SETUP_PLATFORM}; do