elasticdog / transcrypt

transparently encrypt files within a git repository
MIT License
1.46k stars 102 forks source link

Transcrypt version and help output not displayed outside git repositories #68

Closed JensErat closed 4 years ago

JensErat commented 5 years ago

transcrypt --version and transcrypt --help should also work outside git repositories, as they're frequently used to test whether the script is installed correctly. They give no output, though.

Example terminal session:

➜  /tmp mkdir test
➜  /tmp cd test 
➜  test transcrypt --version
➜  test git init
Initialized empty Git repository in /tmp/test/.git/
➜  test git:(master) transcrypt --version
transcrypt 2.0.0

Same applies to transcrypt --help.

Expected behavior: version also displayed outside an initialized git repository.

apeschel commented 4 years ago

I took a quick look, and this is happening due to errexit being set at the start of the script. My personal opinion is that errexit shouldn't be used at all, and that proper error handling should be relied on instead. It looks like transcrypt has pretty good error handling throughout, so it may be fine to remove errexit entirely. Alternatively, turning on could be deferred until after run_safety_checks.