14 lines
736 B
Bash
Executable File
14 lines
736 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
|
usage(){ echo "Usage: $0 INPUT_DIR [--evidence-root DIR]" >&2; exit 2; }
|
|
input_dir=${1:-}; [[ -n "$input_dir" ]]||usage; shift; evidence_root=
|
|
while (($#)); do case $1 in --evidence-root) (($# >= 2))||usage; evidence_root=$2; shift 2;; *) usage;; esac; done
|
|
count=0
|
|
while IFS= read -r -d '' input; do
|
|
arguments=(); [[ -z "$evidence_root" ]]||arguments+=(--evidence-root "$evidence_root")
|
|
"$root/tools/validate.sh" "$input" "${arguments[@]}"; ((count+=1))
|
|
done < <(find "$input_dir" -type f -name '*.json' -print0 | sort -z)
|
|
((count > 0))||{ echo "$input_dir: no JSON diagnostics found" >&2; exit 1; }
|
|
echo "Validated $count diagnostics"
|