fix: \compute_lm_total_eth\ awk parser reads only the line immediately after \== Logs ==\ (#879)

Replace getline-once approach with a forward-scan that skips blank lines
and warning lines after the marker, finding the first digit-only line.
This commit is contained in:
openhands 2026-03-17 15:07:30 +00:00
parent 390586156b
commit 07b117c906

View file

@ -176,8 +176,9 @@ compute_lm_total_eth() {
output=$(cd "$REPO_ROOT" && LM="$LM" WETH="$WETH" POOL="$POOL" \
"$FORGE" script onchain/script/LmTotalEth.s.sol \
--rpc-url "$RPC_URL" --root onchain 2>&1)
# forge script prints "== Logs ==" then " <value>" — extract the number
result=$(echo "$output" | awk '/^== Logs ==/{getline; gsub(/^[[:space:]]+/,""); print; exit}')
# forge script prints "== Logs ==" then " <value>" — extract the number.
# Scan all lines after the marker so blank lines or warning lines don't corrupt the result.
result=$(echo "$output" | awk '/^== Logs ==/{found=1; next} found && /^[[:space:]]*[0-9]+[[:space:]]*$/{gsub(/[[:space:]]/, ""); print; exit}')
[[ -n "$result" && "$result" =~ ^[0-9]+$ ]] || die "Failed to read LM total ETH (forge output: $output)"
echo "$result"
}