Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/release/pypi/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pip list

script_dir=`cd $(dirname $BASH_SOURCE[0]); pwd`

if [[ "$branch" != "release" ]]; then
if [[ ! $branch =~ ^release ]]; then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test this regex match:

branch=dev
if [[ ! $branch =~ ^release ]]; then
    echo not a release branch
fi
# output: not a release branch

branch=myfeature
if [[ ! $branch =~ ^release ]]; then
    echo not a release branch
fi
# output: not a release branch

branch=release
if [[ ! $branch =~ ^release ]]; then
    echo not a release branch
fi

branch=release-lts-2.66
if [[ ! $branch =~ ^release ]]; then
    echo not a release branch
fi

Copy link
Member Author

@jiasli jiasli Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double quotes in "$branch" are not necessary. The official Bash doc doesn't quote the first operand:

https://www.gnu.org/software/bash/manual/bash.html#index-_005b_005b

[[ $line =~ ^"initial string" ]]

This is also confirmed by https://unix.stackexchange.com/questions/500828/why-use-double-quotes-in-a-test

From the output of set -x, we can see there is no difference:

set -x
branch="with a space"

if [[ $branch =~ ^release ]]; then
    echo matched
fi
# output: + [[ with a space =~ ^release ]]

if [[ "$branch" =~ ^release ]]; then
    echo matched
fi
# output: + [[ with a space =~ ^release ]]

. $script_dir/../../ci/version.sh post`date -u '+%Y%m%d%H%M%S'`
fi

Expand Down
Loading