3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos
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
..
doc Merge pull request #179220 from romildo/fix.xfconf 2022-06-30 07:39:27 -03:00
lib nixos/make-options-doc: Support Nix-provided declaration locations 2022-06-27 22:07:20 +02:00
maintainers
modules treewide: fix bash exit handlers 2022-07-02 16:13:12 +02:00
tests Merge pull request #179425 from McSinyx/phylactery 2022-06-30 18:29:19 +03:00
COPYING
default.nix
README
release-combined.nix
release-small.nix
release.nix nixos/release.nix: expose a kexec.$system attribute 2022-06-09 20:00:26 +02:00

*** NixOS ***

NixOS is a Linux distribution based on the purely functional package
management system Nix.  More information can be found at
https://nixos.org/nixos and in the manual in doc/manual.