[bash] error comparing a variable to a string (solved)

I'm working on a bash script that navigates through a cloud path, and I'm getting the error -bash: [[: gs://: syntax error in expression (error token is "://")

To me, this indicates that bash is attempting to evaluate the variable instead of comparing strings, but I have no clue why that would be the case.

This is the relevant code:

GSPATH='gs://'
if [[ "$GSPATH" -eq 'gs://' ]]; then
    echo 'empty'
1 points · 1 comments · view on lemmy.world

1 Comments

rockSlayer@lemmy.blahaj.zone · 1 pts · 146d

I found my own solution: -eq seems to only be intended for numerals. The problem is easily fixed by using == instead. I found this out when I changed the if statement from [[ to [ and got a more precise bash error