Hi!

----

The following script tries to use two functions which each seperately
use "getopts" for argument parsing:
-- snip --
function modify_target_param2
{
        usage=":"
        usage="${usage}B:(bi-directional-authentication)"

        while getopts "${usage}" option
        do
                case ${option} in
                "B")
                        bi="${OPTARG}"
                        ;;
                "?")
                        (( OPTIND = ${OPTIND} + 1 ))
                        ;;
                esac
                
        done
}

function modify_target_param
{
set -o xtrace
        usage=":"
        usage="${usage}B:(bi-directional-authentication)"

        while getopts "${usage}" option
        do
                case ${option} in
                "B")
                        bi="${OPTARG}"
                        ;;
                "?")
                        (( OPTIND = ${OPTIND} + 1 ))
                        ;;
                esac
                ${mod} && modify_target_param2 -B enable target
        done
        return 0
}

mod=$1
[[ ${mod} == ~(Elr)(true|false) ]] || exit 10

modify_target_param -B enable target

print "#done"
exit 0
-- snip --

Running this script with ast-ksh.2009-06-22 results in output which
doesn't look right:
1. Running it with argument "false" returns the expected output:
-- snip --
$ ksh93 getoptste.sh
false                                                                           
                                  
+ usage=:
+ usage=':B:(bi-directional-authentication)'
+ getopts ':B:(bi-directional-authentication)' option
+ bi=enable
+ false
+ getopts ':B:(bi-directional-authentication)' option
+ return 0
#done
-- snip --

2. If I run it with argument "true" I get this output:
-- snip --
$ ksh93 getoptste.sh
true                                                                            
                                  
+ usage=:
+ usage=':B:(bi-directional-authentication)'
+ getopts ':B:(bi-directional-authentication)' option
+ bi=enable
+ true
+ modify_target_param2 -B enable target
#done
-- snip --

Why is the "getopts" parsing of function "modify_target_param2"
affecting the parsing in function "modify_target_param" (AFAIK I would
expect that they can each have their independent "getopts" parsing) ?
And why is the "return 0" statement in function "modify_target_param"
not being called ?

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to