Author: dteske
Date: Mon Sep  1 22:53:47 2014
New Revision: 270954
URL: http://svnweb.freebsd.org/changeset/base/270954

Log:
  Fix a bug where command line arguments could be misprocessed if getopts is
  used prior to f_dialog_init() -- e.g., in a script that sets
  DIALOG_SELF_INITIALIZE to NULL, preventing f_dialog_init() from being run
  automaticaly when `dialog.subr' is included. Caused by sub-shell processing
  of arguments inheriting prior value of $OPTIND, used by getopts. Solved by
  unsetting OPTIND prior to [re-]processing of positional arguments.

Modified:
  head/usr.sbin/bsdconfig/share/dialog.subr

Modified: head/usr.sbin/bsdconfig/share/dialog.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/dialog.subr   Mon Sep  1 22:40:31 2014        
(r270953)
+++ head/usr.sbin/bsdconfig/share/dialog.subr   Mon Sep  1 22:53:47 2014        
(r270954)
@@ -2116,6 +2116,7 @@ f_dialog_init()
        f_dprintf "f_dialog_init: ARGV=[%s] GETOPTS_STDARGS=[%s]" \
                  "$ARGV" "$GETOPTS_STDARGS"
        SECURE=`set -- $ARGV
+               unset OPTIND
                while getopts \
                        "$GETOPTS_STDARGS$GETOPTS_EXTRA$GETOPTS_ALLFLAGS" \
                flag > /dev/null; do
@@ -2125,6 +2126,7 @@ f_dialog_init()
                done
        ` # END-BACKTICK
        USE_XDIALOG=`set -- $ARGV
+               unset OPTIND
                while getopts \
                        "$GETOPTS_STDARGS$GETOPTS_EXTRA$GETOPTS_ALLFLAGS" \
                flag > /dev/null; do
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to