/contrib/dialog/samples/form1-help

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 69 lines · 60 code · 7 blank · 2 comment · 5 complexity · 5e79efb710dea340821659a6be91d560 MD5 · raw file

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