-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmptp_wrap.sh
More file actions
36 lines (32 loc) · 822 Bytes
/
Copy pathmptp_wrap.sh
File metadata and controls
36 lines (32 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
set -euo pipefail
MPTP="${MPTP_CMD:-/usr/local/bin/mptp}"
MODE="${1:---ml}"; shift || true
TREE="$1"; shift || true
OUT="$1"; shift || true
SEED="${1:-42}"
if [[ ! -s "$TREE" ]]; then
echo "[mptp-wrap] ERROR: tree file missing: $TREE" >&2; exit 2
fi
mkdir -p "$(dirname "$OUT")"
try() {
echo "[mptp-wrap] trying: $MPTP $MODE $1 $TREE --out $OUT --seed $SEED" >&2
"$MPTP" "$MODE" $1 "$TREE" --out "$OUT" --seed "$SEED" >/dev/null 2> >(tee /tmp/mptp_try.err >&2) && \
[[ -s "$OUT" ]]
}
# Try likely flags in order:
for FLAG in \
"--treefile" \
"--tree_file" \
"--tree-file" \
"--tree" \
"-t"
do
if try "$FLAG"; then
echo "[mptp-wrap] ok with $FLAG" >&2
exit 0
fi
done
echo "[mptp-wrap] all flag variants failed. Last error:" >&2
cat /tmp/mptp_try.err >&2 || true
exit 1