Skip to content

Commit 444a007

Browse files
committed
fix(crc32c): refactor pyenv check to avoid subshell and string comparison
1 parent dc8c583 commit 444a007

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

packages/google-crc32c/scripts/osx/build_python_wheel.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ eval "$(pyenv init --path)"
4040
install_python_pyenv() {
4141
version=$1
4242
escaped_version="${version//./\.}"
43-
44-
if [ -z "$(pyenv versions --bare | grep "^${escaped_version}\b")" ]; then
43+
if ! pyenv versions --bare | grep -q "^${escaped_version}\b"; then
4544
echo "Python $version is not installed. Installing..."
4645
pyenv install $version
4746
echo "Python $version installed."

packages/google-crc32c/scripts/osx/publish_python_wheel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
set -eo pipefail
1717

18-
if [ -z "$(pyenv versions --bare | grep "^3\.10\b")" ]; then
18+
if ! pyenv versions --bare | grep -q "^3\.10\b"; then
1919
echo "Python 3.10 is not installed. Installing..."
2020
pyenv install 3.10
2121
fi

0 commit comments

Comments
 (0)