Skip to content

Commit

Permalink
feat: ensure history file directory exists before creation
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed May 11, 2024
1 parent 7c95e27 commit 862ffa2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gh-find-code
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 862ffa2

Please sign in to comment.