Advertisement
phillips321

sample bash list code

Jul 18th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | None | 0 0
  1. result=$( dialog ... )
  2. for opt in $result
  3. do
  4. case $opt in
  5. A1) : do whatever ;;
  6. A2) : do whatever ;;
  7. B1) : do whatever ;;
  8. B2) : do whatever ;;
  9. esac
  10. done
  11.  
  12.  
  13. #!/bin/bash
  14.  
  15. A1(){ false;}
  16. A2(){ false;}
  17. B1(){ false;}
  18. B2(){ false;}
  19.  
  20. {
  21. eval "$(
  22. dialog --separate-output --output-fd 3 \
  23. --checklist blah 0 0 0 \
  24. A1 foo on \
  25. A2 bar on \
  26. B1 foo on \
  27. B2 foo on \
  28. 3>&1 >&4 4>&- |
  29. sed 's/$/(){ true;}/')"
  30. } 4>&1
  31.  
  32. clear
  33.  
  34. if A1; then
  35.         echo A1 was ticked
  36. fi
  37. if A2; then
  38.         echo A2 was ticked
  39. fi
  40. if B1; then
  41.         echo B1 was ticked
  42. fi
  43. if B2; then
  44.         echo B2 was ticked
  45. fi
  46. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement