charmbracelet / gum

A tool for glamorous shell scripts 🎀
MIT License
17.94k stars 339 forks source link

gum confirm: Handling exit code 130 isn't working anymore #588

Closed mylinuxforwork closed 4 months ago

mylinuxforwork commented 4 months ago

Just tried to test the handling of the exit code 130 CTRL+C on a gum confirm script. When I press CTRL-C the following message appears: unable to run confirm: user aborted and below :: Update canceled.

This is my script:

if gum confirm "DO YOU WANT TO START THE UPDATE NOW?" ;then
    echo ":: Update started."
elif [ $? -eq 130 ]; then
        exit 130
else
    echo ":: Update canceled."
    exit;
fi

Is it possible that the exit code 130 is not supported anymore on gum confirm?

MikaelFangel commented 4 months ago

The exit-code for both "No" and CTRL+C is now 1. You can check this with the following snippet:

gum confirm; echo $?

And the user aborted message is fixed by: #578

mylinuxforwork commented 4 months ago

@MikaelFangel Thanks. But how can a user now abort completely the gum confirm request and exit the script?

MikaelFangel commented 4 months ago

Okay, I investigated it a bit more and the issue you are experiencing is actually linked to the implementation of huh? not handling the user aborted properly. So, it should be fixed by the PR I've linked to this issue now, as it returns the exit code back to 130 as of earlier versions of gum.

Screenshot 2024-05-24 at 22 23 14