Syntax error: unexpected end of file

circle.yml

#1

I have this step in my circle.yml:

- type: shell
  shell: /bin/bash
  command: "if [[ -e /docker/image.tar ]]; then docker load -i /docker/image.tar"

However, I get the below error trying to run it:

/bin/bash: -c: line 1: syntax error: unexpected end of file
Exited with code 1

Since it’s complaining about -c, I’d imagine the command to run isn’t being surrounded by quotes when being passed to the shell?


#2

The if block wasn’t closed. Also, the quotes and shell designator isn’t needed since Bash is default. This will work:

- type: shell
  name: Try Loading Docker Image
  command: if [[ -e /docker/image.tar ]]; then docker load -i /docker/image.tar; fi

Of course, you can still specify your shell manually if you’d like.


#3

Aha! I’ve no idea how I missed that…I’m sure it was valid in my version 1 circle.yml!

Thanks for pointing it out, and also for pointing out the unnecessary shell definition. I wasn’t clear from the docs whether I could skip it, so I put it in. The quotes were just me trying to fix the error!


#4

Fresh eyes is always useful. You’re welcome. I’ll take a look at the doc to see if we could make it clearer.


#5