diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-03 21:08:53 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-03 21:08:53 +0200 |
commit | 5843e3d2a5ec1bb7cd4b802a2e3625ff9eb5e304 (patch) | |
tree | 6daab39edb6353a8df9defa604920edabfd33b46 /common | |
parent | chore(build): Update (diff) | |
download | flake-templates-5843e3d2a5ec1bb7cd4b802a2e3625ff9eb5e304.tar.gz flake-templates-5843e3d2a5ec1bb7cd4b802a2e3625ff9eb5e304.zip |
fix(common/init): Don't delete the init file, if the exit reason was a missing dependency
Diffstat (limited to '')
-rw-r--r-- | common/init | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/common/init b/common/init index 1ea1603..63a72fa 100644 --- a/common/init +++ b/common/init @@ -10,13 +10,17 @@ trap "cleanup; remove_self" EXIT cleanup() { rm "$replacement_file" } +avoid_cleanup="false" remove_self() { - rm "$(realpath "$0")" - rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh" + if [ "$avoid_cleanup" = "false" ]; then + rm "$(realpath "$0")" + rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh" + fi } require() { program="$1" if ! command -v "$program" >/dev/null; then + avoid_cleanup="true" echo "Please install '$program' for this init script to work." 1>&2 exit 1 fi |