/contrib/dialog/samples/form5

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 71 lines · 63 code · 5 blank · 3 comment · 5 complexity · a9f6dba128d6da8d937f28d4f41d2daa MD5 · raw file

  1. #! /bin/sh
  2. # $Id: form5,v 1.6 2010/01/13 10:49:52 tom Exp $
  3. # form4 with --help-status
  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-status \
  17. --help-button \
  18. --item-help \
  19. --backtitle "$backtitle" "$@" \
  20. --form "Here is a possible piece of a configuration program." \
  21. 20 50 0 \
  22. "Username:" 1 1 "$user" 1 10 10 0 "Login name" \
  23. "UID:" 2 1 "$uid" 2 10 8 0 "User ID" \
  24. "GID:" 3 1 "$gid" 3 10 8 0 "Group ID" \
  25. "HOME:" 4 1 "$home" 4 10 40 0 "User's home-directory" \
  26. 2>&1 1>&3`
  27. returncode=$?
  28. exec 3>&-
  29. show=`echo "$value" |sed -e 's/^/ /'`
  30. case $returncode in
  31. $DIALOG_CANCEL)
  32. "$DIALOG" \
  33. --clear \
  34. --backtitle "$backtitle" \
  35. --yesno "Really quit?" 10 30
  36. case $? in
  37. $DIALOG_OK)
  38. break
  39. ;;
  40. $DIALOG_CANCEL)
  41. returncode=99
  42. ;;
  43. esac
  44. ;;
  45. $DIALOG_OK)
  46. "$DIALOG" \
  47. --clear \
  48. --backtitle "$backtitle" --no-collapse --cr-wrap \
  49. --msgbox "Resulting data:\n\
  50. $show" 10 40
  51. ;;
  52. $DIALOG_HELP)
  53. "$DIALOG" \
  54. --clear \
  55. --backtitle "$backtitle" --no-collapse --cr-wrap \
  56. --msgbox "Help data:\n\
  57. $show" 10 40
  58. ;;
  59. *)
  60. echo "Return code was $returncode"
  61. exit
  62. ;;
  63. esac
  64. done