freebsd-dev/usr.sbin/bsdconfig/share
Devin Teske 5b4765c331 Fix option processing from the library layer to address unexpected
behavior(s); e.g., `-Xd' versus `-dX' did not produce the same results.

The libraries common.subr and dialog.subr automatically process the
arguments passed to the program and enable/disable functionality without the
need to process the arguments within your program. For example, if "$@"
contains `-d', common.subr will see this and enable debugging regardless of
whether you process "$@" yourself or not (this automatic processing can
easily be disabled for custom scripts that don't want it; see the afore-
mentioned scripts for additional details).

NOTE: common.subr stores a copy of "$@" in $ARGV for convenient (and
repeated) processing by libraries such as dialog.subr which provide such
transparent functionality for the consuming script(s).

However, the libraries don't know if a program wants to accept `extra'
options. Flags are not really a problem, because the library can be
programmed to silently ignore unknown flags. The trouble comes into play
when the program wants to define an option that takes an argument.

For example:

	bsdconfig -D logfile -X

In the above example, the library uses getopts to process $ARGV and if it
doesn't know that `-D' takes an argument, the option processing will
prematurely terminate on `logfile' (this is standard/correct behavior for
getopts but is undesired in our situation where we have partially off-loaded
main argument processing).

The problem is solved by allowing the program to define an extra set of
options to be included in each library's handling of $ARGV. Only options
that require arguments are truly necessary to be pre-specified in this new
manner.
2013-06-02 22:04:39 +00:00
..
media Standardize the way functions build their arguments leading up to a dialog 2013-06-02 20:02:50 +00:00
packages Standardize the way functions build their arguments leading up to a dialog 2013-06-02 20:02:50 +00:00
common.subr Fix option processing from the library layer to address unexpected 2013-06-02 22:04:39 +00:00
device.subr Improve portion of the dialog(1) API in dialog.subr responsible for 2013-06-01 23:58:44 +00:00
dialog.subr Fix option processing from the library layer to address unexpected 2013-06-02 22:04:39 +00:00
Makefile Commit first portion of package module -- this includes the ability to view 2013-05-07 05:40:20 +00:00
mustberoot.subr Standardize the way functions build their arguments leading up to a dialog 2013-06-02 20:02:50 +00:00
script.subr Commit first portion of package module -- this includes the ability to view 2013-05-07 05:40:20 +00:00
strings.subr Fix a typo in a comment. 2013-05-16 16:51:52 +00:00
struct.subr Import media selection/preparation framework (sysinstall inspired). Makes 2013-02-25 19:55:32 +00:00
sysrc.subr Add more debugging to help with diagnosis of program-flow when needed. 2012-12-25 10:47:45 +00:00
variable.subr Similar to r251236, improve the portion of dialog(1) API in dialog.subr 2013-06-02 05:45:25 +00:00