From 56030912d72cf6e4a1defb93ca9fe846f4b181d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Mon, 7 Jul 2025 22:17:24 +0200 Subject: [PATCH] bugfix: load variables and functions only once --- src/main.sh | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main.sh b/src/main.sh index 0d7d3c5..e938148 100644 --- a/src/main.sh +++ b/src/main.sh @@ -2,17 +2,24 @@ set -eu -# Helper functions -. "sh/helper.sh" - -# Read theme -. "sh/theme.sh" - -# Read configuration -. "sh/config.sh" - -# Load awk scripts -. "sh/awkscripts.sh" +if [ ! "${SCRIPT_LOADED:-}" ]; then + # Helper functions + . "sh/helper.sh" + # Read theme + . "sh/theme.sh" + # Read configuration + . "sh/config.sh" + # Load awk scripts + . "sh/awkscripts.sh" + # iCalendar routines + . "sh/icalendar.sh" + # Attachment handling + . "sh/attachment.sh" + # Categories handling + . "sh/categories.sh" + # Mark as loaded + export SCRIPT_LOADED=1 +fi __lines() { find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \ @@ -90,9 +97,6 @@ Examples: exit fi -# iCalendar routines -. "sh/icalendar.sh" - # Command line arguments: Interal use . "sh/cliinternal.sh" @@ -102,12 +106,6 @@ fi # Parse command-line filter (if any) . "sh/filter.sh" -# Attachment handling -. "sh/attachment.sh" - -# Categories handling -. "sh/categories.sh" - if [ -n "${list_option:-}" ]; then __lines | $FZF \