[Whiptail checklist] Difference between 'nothing checked' and 'canceled'
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 |
you can find some ideas here: https://en.wikibooks.org/wiki/Bash_S...pting/Whiptail
In general: Code:
result=$(whiptail --title "$TITLE" --checklist "deselect to disable" 15 50 5 "${options[@]}" 3>&1 1>&2 2>&3) |
Quote:
$? was in a previous version of the script, but in the current would not serve any purpose. I understand the call to eval (which is necessary but I forgot why after some dozen modifications) comes just too early. Thank you very much. This is better than you may even guess. |
My current script still looks clumsy, but works (again).
For the intended use, I feed it a temporary file (from mktemp), a test can be made with just any writable or inexistent file as only argument, like in : Code:
kong@bomb:~/ whiptail_dlg /tmp/test.out Code:
#!/bin/bash |
Woah, that double tab indentation level is a bit much. I couldn't cope working with that much whitespace.
|
Quote:
This vim installation is not yet configured beyond the defaults. And I indented this way only before copy&pasting here. ;) Wrong. The indentation rules for bash/sh scripts just do not conform. All other codes (Ruby) were okay. I have overruled with my own indentation settings in .vimrc, now. |
All times are GMT -5. The time now is 02:27 PM. |