new function for "list" type queries

Auke Kok sofar at foo-projects.org
Mon Jul 10 18:46:31 UTC 2006


Jon South wrote:
> This is a new function to be used in CONFIGURE to allow lists of answers 
> (where yes or no would not work) for a single option. As an example, the 
> attached apache2 module diff uses it to select an MPM module (prefork or 
> worker).
> 
> I've tested it and it works okay, and should support any number of 
> options. Constructive criticism, critiques, suggestions, opinions, 
> arguments, quarrels, flames, and insults are all welcome.

I don't like the "|" character as a separator, and I think it should be 
removed. Not only would strange things happen if accidentally someone sh'd a 
CONFIGURE file, it also isn't the standard style we've been using

can you rewrite it so the format would become:

 > +lquery MPM "Please select a Multi-Processing Module (MPM)." 
"prefork|Prefork (Default)" "worker|Worker"

lquery MPM "Please select a Multi-Processing Module (MPM)." \
        "prefork" "Prefork thread model (Default)" \
        "worker" "Worker thread model (recommended when using NPTL threads)"

this would also be much more readable.

Auke



> 
> -Striker
> 
> 
> ------------------------------------------------------------------------
> 
> --- messages.lunar     2006-03-21 14:06:02.000000000 -0600
> +++ messages.lunar        2006-07-07 11:17:26.000000000 -0500
> @@ -167,7 +167,7 @@
>  
>  # mquery is a wrapper to autodetect if a certain y/n parameter in a module
>  # config is not set yet and handles the case in a single function
> -# usage: mqeury USE_LILO "Use lilo instead of grub" ?
> +# usage: mquery USE_LILO "Use lilo instead of grub" ?
>  # note : $MODULE must be set properly
>  mquery()
>  {
> @@ -185,6 +185,42 @@
>  }
>  
>  
> +# lquery is a wrapper to autodetect if a certain parameter in a module
> +# config is not set yet and handles the case in a single function
> +# usage:   lquery <VARIABLE> "<Question Description>" "<Value>|<Description>" ...
> +# example: lqeury MPM "Please select a Multi-Processing Module (MPM)." "prefork|Prefork (Default)" "worker|Worker"
> +# note:    $MODULE must be set properly
> +lquery()
> +{
> +    debug_msg "lquery ($@)"
> +    if [ -n "$MODULE" ]; then
> +        if [ -z "$(get_module_config $1)" ]; then
> +            # it's not set yet... start the asking loop
> +            OPTION=$1
> +            shift
> +            QUESTION=$1
> +            shift
> +            while true ; do
> +                error_message "${MESSAGE_COLOR}$QUESTION${DEFAULT_COLOR}"
> +                ((N=0))
> +                for TARGET ; do
> +                    ((N++))
> +                    TARGETVAL[$N]=$(echo $TARGET | cut -d\| -f1)
> +                    error_message "  ${QUERY_COLOR}$N${MESSAGE_COLOR} - ${DEFAULT_COLOR}${MODULE_COLOR}$(echo $TARGET | cut -d\| -f2)${DEFAULT_COLOR}"
> +                done
> +                echo -n "Choice: "
> +                read CHOICE
> +                if [[ -n "$CHOICE" && -n "${TARGETVAL[$CHOICE]}" ]] ; then
> +                    set_module_config $OPTION ${TARGETVAL[$CHOICE]}
> +                    return
> +                fi
> +                error_message "${MESSAGE_COLOR}Sorry, I can't do anything with \"${DEFAULT_COLOR}${QUERY_COLOR}$CHOICE${DEFAULT_COLOR}${MESSAGE_COLOR}\", please try again${DEFAULT_COLOR}"
> +            done
> +        fi
> +    fi
> +}
> +
> +
>  color()  {
>    debug_msg "color ($@)"
>    case  $1  in
> 
> 
> 


More information about the Lunar-dev mailing list