From owner-freebsd-questions@FreeBSD.ORG Sun Jun 6 03:56:23 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E6B5106564A for ; Sun, 6 Jun 2010 03:56:23 +0000 (UTC) (envelope-from aiza21@comclark.com) Received: from avmxsmtp3.comclark.com (avmxsmtp3.comclark.com [202.69.191.117]) by mx1.freebsd.org (Postfix) with ESMTP id 29FE88FC18 for ; Sun, 6 Jun 2010 03:56:21 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsIZAGq5CkzKRa1aPGdsb2JhbAAHgxaEUpZxAQEBATWtXI9igSaDA24Eg0g X-IronPort-AV: E=Sophos;i="4.53,370,1272816000"; d="scan'208";a="2193267" Received: from unknown (HELO [10.0.10.3]) ([202.69.173.90]) by avmxsmtp2.comclark.com with ESMTP; 06 Jun 2010 11:56:18 +0800 Message-ID: <4C0B1C61.9030501@comclark.com> Date: Sun, 06 Jun 2010 11:56:17 +0800 From: Aiza User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Dan Nelson References: <201006051513.o55FDCKj020952@mail.r-bonomi.com> <4C0ADBCF.8040506@comclark.com> <20100606014737.GG85961@dan.emsphone.com> In-Reply-To: <20100606014737.GG85961@dan.emsphone.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: "questions@freebsd.org" Subject: Re: .sh & getopts X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2010 03:56:23 -0000 > > /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