From 093a6fd54218ae17ff1531e8e18fff96b6c17f13 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Wed, 23 Oct 2024 15:56:58 +0000 Subject: [PATCH] tests: Add trap statement in kata doc script This PR adds the trap statement into the kata doc script to clean up properly the temporary files. Signed-off-by: Gabriela Cervantes --- tests/kata-doc-to-script.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/kata-doc-to-script.sh b/tests/kata-doc-to-script.sh index 126073fd57..7ecce4efcf 100755 --- a/tests/kata-doc-to-script.sh +++ b/tests/kata-doc-to-script.sh @@ -168,6 +168,7 @@ doc_to_script() all=$(mktemp) body=$(mktemp) + trap 'rm -f $body $all' EXIT cat "$file" |\ sed -n "/^ *${bash_block_open}/,/^ *${block_close}/ p" |\ @@ -188,9 +189,6 @@ doc_to_script() # create output file [ "$check_only" = "no" ] && cp "$all" "$outfile" - - # clean up - rm -f "$body" "$all" } main()