Skip to content

Prevent special character in variable from executing on echo #25947

Discussion options

You must be logged in to vote

The problem is that there are no spaces after [[ and before ]]. The [[ is a bash command, and without the space it’s combined with the first word in the $commitMessage variable instead, which is no valid command. Additionally string comparison with the [[ or [ commands is just one equals sign. Finally you should quote both sides of the comparison.

So your if needs to be:

        if [[ "$commitMessage" = "chore(release): publish" ]]; then

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Packages Host your dependencies, libraries, and production-ready code, right from your repository Product Feedback
2 participants