I got some troubles when managing dialog output and exit codes. Essentially I'm trying to get a one-line script for getting dialog selection and terminate script function:
local _ui_envname=$(dialog --stdout --cancel-label "Back" --inputbox 'Enter the new environment name:' 0 0) || { echo "Failed"; exit 1; }
However the above command fails miserably (the { echo "Failed"; exit 1; }
is not executed at all when dialog
exit code is 1). The culprit seems to be the local
keyword: removing the local variable specifier it starts working as expected.
What is going on? Am I doomed to use "global" variables?