scripts: default to non-interactive mode.

This commit is contained in:
Jonathan Moore Liles 2012-10-31 12:54:21 -07:00
parent 31cbec8a16
commit 9897655a9e
1 changed files with 13 additions and 13 deletions

View File

@ -28,8 +28,8 @@ fatal ()
exit 255 exit 255
} }
UPDATE=no
HELP=no HELP=no
INTERACTIVE=no
split () split ()
{ {
@ -43,14 +43,14 @@ split ()
if [ $# -gt 0 ] if [ $# -gt 0 ]
then then
case "$1" in case "$1" in
--update) --help|-h)
UPDATE=yes
shift 1
;;
--help)
HELP=yes HELP=yes
shift 1 shift 1
;; ;;
--interactive|-i)
INTERACTIVE=yes
shift 1
;;
*) *)
# fatal "This is not an autoconf script. Run it without any options and you will be prompted." # fatal "This is not an autoconf script. Run it without any options and you will be prompted."
;; ;;
@ -67,11 +67,11 @@ s/--enable-\([^ =]\+\)/USE_\1=yes/g;
s/--disable-\([^ =]\+\)/USE_\1=no/g; s/--disable-\([^ =]\+\)/USE_\1=no/g;
s/--\([^ =]\+\)/\1/g; s/--\([^ =]\+\)/\1/g;
' | sed -n '/^[^ =]\+=./p' >> .config ' | sed -n '/^[^ =]\+=./p' >> .config
UPDATE=yes; INTERACTIVE=no;
fi fi
fi fi
if [ $HELP != yes ] && [ $UPDATE != yes ] if [ $HELP != yes ] && [ $INTERACTIVE != no ]
then then
if ! ( [ -t 0 ] && [ -t 1 ] ) if ! ( [ -t 0 ] && [ -t 1 ] )
then then
@ -102,7 +102,7 @@ ask ()
echo -n "$BLACK$BOLD::$SGR0 ${1}? [$BOLD${D}$SGR0] " echo -n "$BLACK$BOLD::$SGR0 ${1}? [$BOLD${D}$SGR0] "
if [ $UPDATE = yes ] if [ $INTERACTIVE = no ]
then then
A="$D" A="$D"
echo echo
@ -207,7 +207,7 @@ begin_options ()
if [ $HELP = yes ] if [ $HELP = yes ]
then then
echo echo
warn "This is a ${BOLD}non-configure${SGR0} script. Run without any arguments and you will be prompted" warn "This is a ${BOLD}non-configure${SGR0} script. Run with ${BOLD}--interactive${SGR0} argument and you will be prompted"
warn "with configuration choices. Alternatively, you may use the following autoconf style" warn "with configuration choices. Alternatively, you may use the following autoconf style"
warn "arguments for non-interactive configuration." warn "arguments for non-interactive configuration."
echo echo
@ -218,11 +218,11 @@ begin_options ()
append "# This file was automatically generated on `date`. Any changes may be lost!" append "# This file was automatically generated on `date`. Any changes may be lost!"
append "## options" append "## options"
if [ $UPDATE = yes ] if [ $INTERACTIVE = no ]
then then
info "Updating configuration" info "Non-interactively updating configuration"
else else
info "Configuration required" info "Interactive configuration requested"
fi fi
fi fi
} }