From 57db6a16fa80b01a6a3324a2eaa0e620e588ab6e Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Mon, 6 Jul 2026 14:00:11 +0000 Subject: [PATCH] multicurl: fix cat: '': No such file or directory when called without -o MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit $temp_file is only created when curl is invoked with -o (the -o loop above), but the post-success null/error check always ran `cat "$temp_file"`. When a caller omits -o (e.g. check-health.sh's Cosmos reference RPC), the variable is empty, so bash executed `cat ""` and printed "cat: '': No such file or directory" — once per show-status run. In that no-o case the body is already captured in $output, so read the response from $output when $temp_file is unset, and from $temp_file when it exists. Behaviour with -o is unchanged; the result==null / JSON-RPC error skip-to-next-URL fallback is preserved in both paths. Co-Authored-By: Claude --- multicurl.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/multicurl.sh b/multicurl.sh index 026c37ac..7ae6d1f5 100755 --- a/multicurl.sh +++ b/multicurl.sh @@ -47,7 +47,14 @@ for url in "${urls[@]}"; do # null result (a lagging endpoint that doesn't have the requested block/data yet). # Without the result==null check the first endpoint's {"result":null} was accepted as # success and the remaining fallback URLs were never tried. - if cat "$temp_file" | jq -e 'has("error") or (.result == null)' > /dev/null 2>&1; then + # $temp_file only exists when curl was called with -o (see the -o loop above). + # When a caller omits -o, the body is already in $output, so reading cat "" would + # emit "cat: '': No such file or directory". Read from whichever place holds the body. + response_body="$output" + if [ -n "$temp_file" ]; then + response_body=$(cat "$temp_file") + fi + if echo "$response_body" | jq -e 'has("error") or (.result == null)' > /dev/null 2>&1; then continue # Try the next URL fi