Sample Header Ad - 728x90

Show dialog gauge while preserving function exit code

0 votes
1 answer
45 views
This function sends api requests.
api_req() {
    # req 1 else return 1
    echo 33
    # req 2 else return 1
    echo 66
    # req 3 else return 1
    echo 100
}
This will return 1 when any of the request fails. Now, I want to pass it to **dialog** gauge. Like this,
if ! api_req | dialog --gauge "Sending requests" -1 -1 0; then
    echo "api requests failed!!"
fi
But it can't detect the fail. I also tried api_req > >(dialog ...), but this way the dialog is not shown. How can I get it working?
Asked by decipher (352 rep)
Nov 7, 2024, 08:28 PM
Last activity: Nov 8, 2024, 02:13 PM