0

I want to check if i am stay in the dev branch, my file .sh have this content:

let current = GIT branch --show-current

if  current == "dev"

but it does not worked, i am getting this error:

line 3: let: =: syntax error: operand expected (error token is "=")
signup
  • 135
  • 1
  • 16

1 Answers1

1

let is an obsolete command for performing arithmetic. You want a command substitution. Then you need to use a specific command to perform the comparison; you can use either test or [[ ... ]]

current=$(git branch --show-current)

if [ "$current" = dev ]; then
    echo "On dev branch"
fi

if [[ $current = dev ]]; then
    echo "On dev branch"
fi
chepner
  • 497,756
  • 71
  • 530
  • 681