clojure-control icon indicating copy to clipboard operation
clojure-control copied to clipboard

Handle errors by stopping execution

Open nha opened this issue 10 years ago • 0 comments

Hello again :)

I came across a case that I think could be improved (unless I missed something and it is already present). Here was the output from my console when running clojure-control :

localhost:ssh:  cd /var/dev/my-repo/ ; git clone [email protected]:nha/my-repo.git
localhost:stderr: zsh:cd:1: no such file or directory: /var/dev/my-repo/
Cloning into 'my-repo'...
localhost:exit: 0

As you can see, the cd command failed because the directory didn't exist. And then the clone command fired up anyway. So the clone ended up in my home repository.

I can see two possible solutions :

  • replace the ";" delimiter with a "&&" delimiter. This is probably a quick-fix, and it relies on commands to return standard success/error codes.

  • set bash flags for the duration of the command :

    set -o errexit set -o pipefail set -o nounset

What do you think ?

Thank you for making this library.

nha avatar Aug 31 '15 15:08 nha