Closed bew closed 3 years ago
Default is that Cancel button always returns 1. But custom buttons with exit code can be defined.
TEXT=$(yad --entry --button="OK":2 --button="Cancel":3)
echo "exit code: $?"
[[ -z "${TEXT// }" ]] && echo "TEXT is empty or contains only whitespaces"
Checking if variable is empty:
TEXT=$(yad --entry --button="OK":2 --button="Cancel":3)
status=$?
case $status in
0) echo "Enter you typed: ${TEXT}" ;
[[ -z "${TEXT// }" ]] && echo "+ TEXT is empty or contains only spaces" ;;
2) echo "Ok button press" ;
[[ -z "${TEXT// }" ]] && echo "+ TEXT is empty or contains only spaces" ;;
3) echo "Cancel button press" ;;
*) echo "Window closed or escape key pressed - exit code: ${status}" ;;
esac
Yess, I missed that somehow in my scripts, sorry for the noise :+1:
Hello, I'm using the
--entry
mode to ask for a small line of text.I'dl like to distinguish between:
Cancel
or pressingEscape
key)Enter
key with an empty inputI was thinking maybe a flag like
--exit-ko-on-cancel
that exit with a non-zero exit code when cancelling?