1
submitted 1 week ago* (last edited 1 week ago) by rockSlayer to c/learn_programming@programming.dev

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'
top 1 comments
sorted by: hot top controversial new old
[-] rockSlayer 1 points 1 week ago

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

this post was submitted on 24 Apr 2026
1 points (100.0% liked)

Learn Programming

2172 readers
1 users here now

Posting Etiquette

  1. Ask the main part of your question in the title. This should be concise but informative.

  2. Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.

  3. Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.

  4. Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 2 years ago
MODERATORS