Skip to content

Commit 272f170

Browse files
committed
feat(test/compare.sh): Shellcheck
Signed-off-by: Oliver Gondža <ogondza@gmail.com>
1 parent d8e1000 commit 272f170

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/compare.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env bash
22
# https://github.com/olivergondza/bash-strict-mode
33
set -eEuo pipefail
4+
s=declare_out_of_trap_script # Workaround for https://github.com/koalaman/shellcheck/issues/3287
45
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
56

6-
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
7-
87
function main() {
98
if [[ $# -ne 2 ]]; then
109
echo >&2 "Usage: $0 [IMAGE_A] [IMAGE_B]"
@@ -15,7 +14,7 @@ function main() {
1514

1615
inv_a="$(mktemp -d gitops-must-gather-A-XXXX)"
1716
inv_b="$(mktemp -d gitops-must-gather-B-XXXX)"
18-
trap "rm -rf '${inv_a}' '${inv_b}'" EXIT
17+
trap 'rm -rf "${inv_a}" "${inv_b}"' EXIT
1918

2019
gather "$img_a" "$inv_a"
2120
gather "$img_b" "$inv_b"
@@ -55,8 +54,10 @@ function sanitize() {
5554
"$dir/oc-adm-output.log" "$dir/must-gather.logs" "$dir/__RESOURCES__/gather.logs" "$dir/__RESOURCES__/gather_gitops.log"
5655

5756
# Timestamps are not going to match, just test there is the same number of them
58-
wc -l < "$dir/timestamp" > "$dir/timestamp"
59-
wc -l < "$dir/__RESOURCES__/timestamp" > "$dir/__RESOURCES__/timestamp"
57+
ts="$(wc -l < "$dir/timestamp")"
58+
echo "$ts" > "$dir/timestamp"
59+
ts="$(wc -l < "$dir/__RESOURCES__/timestamp")"
60+
echo "$ts" > "$dir/__RESOURCES__/timestamp"
6061
}
6162

6263
main "$@"

0 commit comments

Comments
 (0)