Skip to content

Commit 1e9467a

Browse files
committed
Add trap to ensure temp file cleanup in SRI script
1 parent 3f9e614 commit 1e9467a

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

calc_sri_fix.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ set -euo pipefail
55
calculate_sri() {
66
url="$1"
77
temp_file=$(mktemp)
8+
trap 'rm -f "$temp_file"' RETURN
89

910
# curl options: -f (fail on HTTP error), -S (show error), -s (silent equivalent), -L (follow redirects)
1011
if ! curl -fS -sL "$url" -o "$temp_file"; then
1112
echo "Error downloading $url" >&2
12-
rm -f "$temp_file"
1313
return 1
1414
fi
1515

1616
# Check for empty response
1717
if [ ! -s "$temp_file" ]; then
1818
echo "Error: Empty response from $url" >&2
19-
rm -f "$temp_file"
2019
return 1
2120
fi
2221

0 commit comments

Comments
 (0)