--- tzdialog-1.0.2.txt 2011-11-27 22:44:17.000104000 +0000 +++ tzdialog-1.1.txt 2012-01-10 00:11:47.000023000 +0000 @@ -2,9 +2,9 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set tabstop=4 :: Vi/ViM # -# Revision: 1.0.2 +# Revision: 1.1 # Created: June 27th, 2011 -# Last Modified: July 5th, 2011 +# Last Modified: November 24th, 2011 ############################################################ COPYRIGHT # # Devin Teske (c)2011. All Rights Reserved. @@ -48,7 +48,7 @@ # # Command Usage: # -# tzdialog [-nsvX] [default] +# tzdialog [-nsvXe] [default] # # OPTIONS: # -n Do not create or copy files. @@ -56,6 +56,10 @@ # not set to UTC. # -v Verbose. Enable extra output when installing the zone file. # -X Enable the use of Xdialog(1) instead of dialog(1). +# -e Only return success on exit if user selects a timezone AND +# the selected timezone was successfully installed. By default +# (without this flag), success is always returned unless an +# error has occurred. # # Dependencies (sorted alphabetically): # @@ -169,6 +173,8 @@ DIALOG="dialog" # # Settings used while interacting with dialog(1) # +# NOTE: export is required for awk(1) `ENVIRON' visibility +# export DIALOG_MENU_TAGS="1234567890abcdefghijklmnopqrstuvwxyz" # @@ -190,11 +196,17 @@ unset XDIALOG_INFOBOX_TIMEOUT # # Xdialog(1) size considerations -# Uncomment targeted minimum resolution +# Pick a sensible fall-back in-case `Xdialog --print-maxsize' fails. # -XDIALOG_MAX_SIZE="31 105" # for 640x480 -#XDIALOG_MAX_SIZE="40 132" # for 800x600 -#XDIALOG_MAX_SIZE="52 165" # for 1024x768 +#XDIALOG_MAX_SIZE="20 78" # for 720x400 (9:5) +#XDIALOG_MAX_SIZE="24 69" # for 640x480 (4:3) +XDIALOG_MAX_SIZE="31 86" # for 800x600 (4:3) +#XDIALOG_MAX_SIZE="32 90" # for 832x624 (4:3) +#XDIALOG_MAX_SIZE="40 111" # for 1024x768 (4:3) +#XDIALOG_MAX_SIZE="46 126" # for 1152x864 (4:3) +#XDIALOG_MAX_SIZE="51 140" # for 1280x960 (4:3) +#XDIALOG_MAX_SIZE="54 140" # for 1280x1024 (5:4) +#XDIALOG_MAX_SIZE="64 175" # for 1600x1200 (4:3) # # Options @@ -203,6 +215,7 @@ REALLYDOIT=1 SKIPUTC= USE_XDIALOG= VERBOSE= +TZ_OR_FAIL= # # Dummy vars (populated dynamically) @@ -288,6 +301,14 @@ usage() "Verbose. Enable extra output when installing the zone file." eprintf "$optfmt" "-X" \ "Enable the use of Xdialog(1) instead of dialog(1)." + eprintf "$optfmt" "-e" \ + "Only return success on exit if user selects a timezone AND" + eprintf "$optfmt" "" \ + "the selected timezone was successfully installed. By default" + eprintf "$optfmt" "" \ + "(without this flag), success is always returned unless an" + eprintf "$optfmt" "" \ + "error has occurred." die } @@ -338,7 +359,7 @@ longest_line_length() # # COUNTRIES # A space-separated list of 2-character country codes. -# country_*_name +# country_CODE_name # The country `name' (as described above). # # where CODE is the 2-character country code. @@ -735,6 +756,9 @@ read_zones() # Sorts alphabetically the 2-character country codes listed in $COUNTRIES based # on the name of each country. # +# This function is a two-parter. Below is the awk(1) portion of the function, +# afterward is the sh(1) function which utilizes the below awk script. +# sort_countries_awk=' { split($0, array, /[[:space:]]+/) @@ -807,6 +831,9 @@ sort_countries() # list of zones for said country represented by *, the 2- # character country code. # +# This function is a two-parter. Below is the awk(1) portion of the function, +# afterward is the sh(1) function which utilizes the below awk script. +# make_menus_awk=' function add_zone_n_to_country_menu(tlc, n) { @@ -1368,12 +1395,13 @@ dialog_menu_root() # # Process command-line arguments # -while getopts nsvX flag; do +while getopts nsvXe flag; do case "$flag" in n) REALLYDOIT=;; s) SKIPUTC=1;; v) VERBOSE=1;; X) USE_XDIALOG=1;; + e) TZ_OR_FAIL=1;; \?) usage;; esac done @@ -1401,6 +1429,22 @@ if [ "$USE_XDIALOG" ]; then fi # +# Probe Xdialog(1) for maximum height/width constraints +# +if [ "$USE_XDIALOG" ]; then + maxsize=$( $DIALOG --print-maxsize 2>&1 ) \ + && XDIALOG_MAX_SIZE=$( + set -- ${maxsize##*:} + + height=${1%,} + width=$2 + + echo $height $width + ) + unset maxsize +fi + +# # DIALOG fixup (FreeBSD-9.0 dialog(1) and Linux dialog(1) support the # `--defaultno' command-line argument. # @@ -1502,7 +1546,7 @@ while :; do if [ $retval -ne 0 ]; then [ ! "$USE_XDIALOG" ] && $DIALOG --clear - [ $retval -ne 1 ] && die + [ "$TZ_OR_FAIL" ] && die exit $SUCCESS fi