/contrib/dialog/samples/mixedform

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 61 lines · 56 code · 3 blank · 2 comment · 5 complexity · f607edf48e6e281256f0ad7a53ab6317 MD5 · raw file

  1. #! /bin/sh
  2. # $Id: mixedform,v 1.6 2010/01/13 10:47:35 tom Exp $
  3. . ./setup-vars
  4. backtitle="An Example for the use of --mixedform:"
  5. returncode=0
  6. while test $returncode != 1 && test $returncode != 250
  7. do
  8. returncode=$?
  9. exec 3>&1
  10. value=`$DIALOG --title "Mixed form demonstration" --ok-label "Submit" \
  11. --backtitle "$backtitle" \
  12. --insecure "$@" \
  13. --mixedform "Here is a possible piece of a configuration program." \
  14. 20 50 0 \
  15. "Username :" 1 1 "Kiran" 1 20 10 0 2 \
  16. "Password :" 2 1 "" 2 20 8 0 1 \
  17. "Retype Password :" 3 1 "" 3 20 8 0 1 \
  18. "HOME :" 4 1 "Cisco" 4 20 40 0 0 \
  19. 2>&1 1>&3`
  20. returncode=$?
  21. exec 3>&-
  22. show=`echo "$value" |sed -e 's/^/ /'`
  23. case $returncode in
  24. $DIALOG_CANCEL)
  25. "$DIALOG" \
  26. --clear \
  27. --backtitle "$backtitle" \
  28. --yesno "Really quit?" 10 30
  29. case $? in
  30. $DIALOG_OK)
  31. break
  32. ;;
  33. $DIALOG_CANCEL)
  34. returncode=99
  35. ;;
  36. esac
  37. ;;
  38. $DIALOG_OK)
  39. "$DIALOG" \
  40. --clear \
  41. --backtitle "$backtitle" --no-collapse --cr-wrap \
  42. --msgbox "Resulting data:\n\
  43. $show" 10 40
  44. ;;
  45. $DIALOG_HELP)
  46. echo "Button 2 (Help) pressed."
  47. exit
  48. ;;
  49. $DIALOG_EXTRA)
  50. echo "Button 3 (Extra) pressed."
  51. exit
  52. ;;
  53. *)
  54. echo "Return code was $returncode"
  55. exit
  56. ;;
  57. esac
  58. done