Skip to content

Commit

Permalink
Allow user to Ctrl+c to exit the function
Browse files Browse the repository at this point in the history
  • Loading branch information
evertramos committed Sep 27, 2023
1 parent aed77af commit 43c7058
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions confirm/confirm-user-action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

confirm_user_action()
{
trap '
trap - INT # restore default INT handler
kill -s INT "$$"
' INT

local LOCAL_USER_RESPONSE LOCAL_USER_QUESTION LOCAL_KILL_SCRIPT LOCAL_INVERT_DEFAULT

LOCAL_USER_QUESTION="${1:-Are you sure you want to continue?}"
Expand Down
5 changes: 5 additions & 0 deletions select/select-multiple-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

select_multiple_data()
{
trap '
trap - INT # restore default INT handler
kill -s INT "$$"
' INT

GLOBAL_MULTIDATA_SELECT_DATA=(${1})

[[ $GLOBAL_MULTIDATA_SELECT_DATA == "" || ${#GLOBAL_MULTIDATA_SELECT_DATA[@]} -eq 0 ]] && echoerror "You must inform the required argument(s) to the function: '${FUNCNAME[0]}'"
Expand Down

0 comments on commit 43c7058

Please sign in to comment.