/contrib/dialog/samples/form3

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 69 lines · 59 code · 7 blank · 3 comment · 5 complexity · a64497f27e2c906e45e2237a1f1ed7af MD5 · raw file

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