Merge pull request 'fix: compute_lm_total_eth awk parser reads only the line immediately after == Logs == (#879)' (#923) from fix/issue-879 into master

This commit is contained in:
johba 2026-03-17 16:46:42 +01:00
commit bce6d5ddce

View file

@ -176,8 +176,9 @@ compute_lm_total_eth() {
output=$(cd "$REPO_ROOT" && LM="$LM" WETH="$WETH" POOL="$POOL" \ output=$(cd "$REPO_ROOT" && LM="$LM" WETH="$WETH" POOL="$POOL" \
"$FORGE" script onchain/script/LmTotalEth.s.sol \ "$FORGE" script onchain/script/LmTotalEth.s.sol \
--rpc-url "$RPC_URL" --root onchain 2>&1) --rpc-url "$RPC_URL" --root onchain 2>&1)
# forge script prints "== Logs ==" then " <value>" — extract the number # forge script prints "== Logs ==" then " <value>" — extract the number.
result=$(echo "$output" | awk '/^== Logs ==/{getline; gsub(/^[[:space:]]+/,""); print; exit}') # 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)" [[ -n "$result" && "$result" =~ ^[0-9]+$ ]] || die "Failed to read LM total ETH (forge output: $output)"
echo "$result" echo "$result"
} }