Why is branch being set to 'm' rather than 'master' in this example?
$ branch="[master]"
$ echo $branch
m
This happens from any directory I am in, but only on my mac and not on one of my linux boxes.
Why is branch being set to 'm' rather than 'master' in this example?
$ branch="[master]"
$ echo $branch
m
This happens from any directory I am in, but only on my mac and not on one of my linux boxes.
Looks like file name expansion, do you have a file in the current directory called m?
echo * or touch a b c; echo [abcdefghijklmnopqrstuvwxyz] - It lists files which match the expression. If you want to avoid expansion, Use More Quotes.Indeed, just like unwind says, this has to do with file name expansion.
[15:33] ~$ branch="[master]"
[15:33] ~$ echo $branch
[master]
[15:33] ~$ touch m
[15:33] ~$ echo $branch
m
[15:33] ~$
There must be a file or directory in your current directory named m.
A possible remedy for this is to use quoting:
$ ls m # `m' exists
m
$ echo "$branch" # yet this echoes "[master]"
[master]