From 409351aa70c4c5d42a5448a76973307fa9d4598e Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Tue, 30 Dec 2025 20:41:27 +0800 Subject: [PATCH] Create md file if it doesn't exist yet. --- kbtd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kbtd b/kbtd index ac30ff3..9c43f15 100755 --- a/kbtd +++ b/kbtd @@ -61,6 +61,15 @@ fi # --- Path Resolution --- +# Create file if it doesn't exist (but only if directory exists) +if [[ ! -f "$FILE_PATH" ]]; then + DIR_PATH=$(dirname "$FILE_PATH") + if [[ ! -d "$DIR_PATH" ]]; then + error_exit "Directory does not exist: $DIR_PATH" + fi + touch "$FILE_PATH" +fi + # Resolve absolute path if [[ "$OSTYPE" == "linux-gnu"* ]]; then ABS_PATH=$(realpath "$FILE_PATH")