From 5843e3d2a5ec1bb7cd4b802a2e3625ff9eb5e304 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 3 Aug 2024 21:08:53 +0200 Subject: fix(common/init): Don't delete the init file, if the exit reason was a missing dependency --- common/init | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'common/init') 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 -- cgit 1.4.1