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

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -