Commit Graph

3 Commits

Author SHA1 Message Date
Erik Arvstedt
3f54dfa475
treewide: fix bash exit handlers
Transform exit handlers of the form
trap cleanup EXIT [INT] [TERM] [QUIT] [HUP] [ERR]
  (where cleanup is idempotent)
to
trap cleanup EXIT

This fixes a common bash antipattern.

Each of the above signals causes the script to exit. For each signal,
bash first handles the signal by running `cleanup` and then runs
`cleanup` again when handling EXIT.
(Exception:  `vscode/*` prevents the second run of `cleanup` by removing
the trap in cleanup`).

Simplify the cleanup logic by just trapping exit, which is always run
when the script exits due to any of the above signals.

Note: In case of borgbackup, the exit handler is not idempotent, but just
trapping EXIT guarantees that it's only run once.
2022-07-02 16:13:12 +02:00
Erik Arvstedt
bb7867f1e5
vscode: simplify helper scripts
This simplifies the following commit.

- Remove `--` from `rm` because `$tmpDir` is guaranteed to never start
  with a `-`.
  We also don't use this pattern when removing tmpDirs at other places
  in nixpkgs.
- Remove `unset tmpDir` because the variable `tmpDir` is never
  accessed after the exit handler is run.
2022-07-02 16:12:51 +02:00
AndersonTorres
8f868e154c Move misc/vscode-extensions to applications/editors/vscode/extensions 2022-02-18 08:25:22 -03:00