/contrib/dialog/samples/form1-utf8

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 71 lines · 61 code · 8 blank · 2 comment · 5 complexity · 980d9a060e31152258f92fb7461a1438 MD5 · raw file

  1. #! /bin/sh
  2. # $Id: form1-utf8,v 1.7 2010/01/13 10:47:35 tom Exp $
  3. . ./setup-vars
  4. . ./setup-utf8
  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="DOG"
  10. home=/usr/home/$user
  11. returncode=0
  12. while test $returncode != 1 && test $returncode != 250
  13. do
  14. exec 3>&1
  15. value=`$DIALOG --ok-label "Submit" \
  16. --backtitle "$backtitle" \
  17. --insecure "$@" \
  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. echo "Button 2 (Help) pressed."
  52. exit
  53. ;;
  54. $DIALOG_EXTRA)
  55. echo "Button 3 (Extra) pressed."
  56. exit
  57. ;;
  58. *)
  59. echo "Return code was $returncode"
  60. exit
  61. ;;
  62. esac
  63. done