From 862ffa25c82aa7a289b89e1e379898309aa3fdc3 Mon Sep 17 00:00:00 2001 From: LangLangbart <92653266+LangLangBart@users.noreply.github.com> Date: Sat, 11 May 2024 15:57:54 +0200 Subject: [PATCH] feat: ensure history file directory exists before creation --- gh-find-code | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gh-find-code b/gh-find-code index 5e389ec..43b7a0c 100755 --- a/gh-find-code +++ b/gh-find-code @@ -267,7 +267,12 @@ validate_environment() { die "$GHFC_HISTORY_FILE is a directory" fi if [[ ! -f $GHFC_HISTORY_FILE ]]; then - touch "$GHFC_HISTORY_FILE" || die "Unable to create: $GHFC_HISTORY_FILE" + command mkdir -p "$(command dirname "${GHFC_HISTORY_FILE}")" + if command touch "$GHFC_HISTORY_FILE"; then + echo "History file successfully created at: $GHFC_HISTORY_FILE" + else + die "Unable to create: $GHFC_HISTORY_FILE" + fi fi [[ -r $GHFC_HISTORY_FILE ]] || die "Permission denied: unable to read from: $GHFC_HISTORY_FILE" [[ -w $GHFC_HISTORY_FILE ]] || die "Permission denied: unable to write to: $GHFC_HISTORY_FILE"