killme2008 / killme2008/clojure-control

Handle errors by stopping execution

Open
#26 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
137
Forks
10
PR merge metrics
No merged PRs in 30d

Description

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 git@github.com: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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported clojure-control command involving `cd` followed by `git clone`, then trace where shell command execution handles the failed `cd`. Done means a failed command prevents the following command from running, with behavior verified for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure, git, shell
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.