Skip to content

Commit bf713b3

Browse files
committed
Refactor trap setup for temporary file cleanup
Simplify trap mechanism by removing separate cleanup function Use inline trap command with shellcheck directive Improve script robustness and readability
1 parent fed15db commit bf713b3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

apply-md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ MARKDOWN=$(cat)
3535
TEMP_DIR=$(mktemp -d)
3636
FILES_FILE="$TEMP_DIR/files.txt"
3737

38-
# Function to cleanup temporary files
39-
cleanup() {
40-
rm -rf "$TEMP_DIR"
41-
}
42-
43-
# Register cleanup on exit
44-
trap cleanup EXIT
38+
# Setup cleanup trap directly without a function
39+
# shellcheck disable=SC2064
40+
trap "rm -rf '$TEMP_DIR'" EXIT
4541

4642
# Extract code blocks and their file names
4743
extract_blocks() {

0 commit comments

Comments
 (0)