shell - Bash scripting unexpected operator -
i'm writing script git hook , have trouble if statement inside while.
file:
#!/bin/sh while read oldrev newref ref branch=$(git rev-parse --symbolic --abbrev-ref $ref) if [ "a" == "a" ] echo "condition work" fi echo "$branch" done error:
hooks/post-receive: 6: [: a: unexpected operator i'll try variables, double quotes if doesn't work. kind of error here?
thanks
if [ "a" == "a" ] should if [ "a" = "a" ].
bash accepts == instead of =, /bin/sh isn't bash.
so either change == =, or shebang #!/bin/bash
Comments
Post a Comment