[SOLVED] [Whiptail checklist] Difference between 'nothing checked' and 'canceled'
by Michael Uplawski from LinuxQuestions.org on (#6J865)
Good afternoon.
Find below a (runnable) extract from a shell script, duplicating the one from https://www.linuxquestions.org/quest...es-4175733242/.
Here, I must learn to discern a situation, where a user does not deselect any item and another, where she/he has clicked 'Cancel' or pushed 'Esc'. I am currently unable to do so, as either *all* items are returned or none and cannot get a return-code (0 or 1 of all choices) or do not know how.
Of course this is all copied and pasted from the Web and other scripts, where I accomplish stuff which has nothing to do with the current task...
Script:
Code:#!/bin/bash
options=(PP 'Post processing' ON GROUP_SIGS 'Signatures' ON CUSTOM_HEADERS 'Custom headers' ON XNAY_GROUPS 'X-No-Archive' ON DEBUG_LOG 'Log' ON)
eval opts=($(whiptail --title "$TITLE" --checklist "deselect to disable" 15 50 5 "${options[@]}" 3>&1 1>&2 2>&3))
echo "|${opts[@]}|"
echo "${#opts[@]}"
Find below a (runnable) extract from a shell script, duplicating the one from https://www.linuxquestions.org/quest...es-4175733242/.
Here, I must learn to discern a situation, where a user does not deselect any item and another, where she/he has clicked 'Cancel' or pushed 'Esc'. I am currently unable to do so, as either *all* items are returned or none and cannot get a return-code (0 or 1 of all choices) or do not know how.
Of course this is all copied and pasted from the Web and other scripts, where I accomplish stuff which has nothing to do with the current task...
Script:
Code:#!/bin/bash
options=(PP 'Post processing' ON GROUP_SIGS 'Signatures' ON CUSTOM_HEADERS 'Custom headers' ON XNAY_GROUPS 'X-No-Archive' ON DEBUG_LOG 'Log' ON)
eval opts=($(whiptail --title "$TITLE" --checklist "deselect to disable" 15 50 5 "${options[@]}" 3>&1 1>&2 2>&3))
echo "|${opts[@]}|"
echo "${#opts[@]}"