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 <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
Gabriela Cervantes 2024-10-23 15:56:58 +00:00
parent 378f454fb9
commit 093a6fd542

View File

@ -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()