/bin/sh can do math on its own:

flag_count=$((flag_count+1))



I want to know if more that one flag has been coded on the command.
So add 1 to counter if that flag was processed. After all the flags are processed and fall out of getopts, then check flag counter for value.

Ok I coded like this


  shift; while getopts biugrs: arg; do case ${arg} in
   b) action="buildworld"; $flag_count=$((flag_count+
   i) action="installworld"; $flag_count=$((flag_count+1));;
   u) action="freebsd-update"; $flag_count=$((flag_count+1));;
   g) action="freebsd-upgrade"; $flag_count=$((flag_count+1));;
   r) action="freebsd-rollback"; $flag_count=$((flag_count+1));;
   s) ezjail_sourcetree=${OPTARG}; $flag_count=$((flag_count+1));;
   ?) exerr ${usage_update};;
   esac; done; shift $(( ${OPTIND} - 1 ))


testing with 4 different flags on the command so should match here.
if $flag_count = 4; then
   echo "yes 4 count"
fi

 exerr "hard stop"



When it runs I get this

=1: not found
0=1: not found
0=1: not found
0=1: not found
0: not found
hard stop


What is still wrong here

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"

Reply via email to