echo

Bash script: how does the $ wildcard work in git script?

I checked that the following is true, but I still don't understand why or how it works:

#!/bin/bash

git checkout production.release.4.2
production_branch=`git branch | grep "production"`

# May not give the expected result:
# the character $ is being treated as a wildcard and will be expanded, so that the output may include all files in the directory:
echo $production_branch
# Using double quotes solve the problem:
echo "$production_branch"

Syndicate content