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:
parent
390586156b
commit
07b117c906
1 changed files with 3 additions and 2 deletions
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue