X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from dal-a2.localdomain (unknown [74.117.189.115]) by mail.alpinelinux.org (Postfix) with ESMTP id 6EEC7DC01BE for ; Wed, 3 Jul 2013 13:30:39 +0000 (UTC) Received: from ncopa-desktop.alpinelinux.org (3.203.202.84.customer.cdi.no [84.202.203.3]) (using SSLv3 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: ncopa@tanael.org) by dal-a2.localdomain (Postfix) with ESMTPSA id 88D71BC2B3B; Wed, 3 Jul 2013 13:30:38 +0000 (UTC) Date: Wed, 3 Jul 2013 15:30:33 +0200 From: Natanael Copa To: Dubiousjim Cc: alpine-devel@lists.alpinelinux.org Subject: Re: [alpine-devel] [PATCH 3/4] update-conf: accept long options Message-ID: <20130703153033.5230023e@ncopa-desktop.alpinelinux.org> In-Reply-To: <6d0295ddc265976445cb2d46c6194db304e92386.1372713126.git.dubiousjim@gmail.com> References: <6d0295ddc265976445cb2d46c6194db304e92386.1372713126.git.dubiousjim@gmail.com> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.17; x86_64-unknown-linux-gnu) X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 1 Jul 2013 17:14:16 -0400 Dubiousjim wrote: > --- > update-conf.in | 40 +++++++++++++++++++++++++--------------- > 1 file changed, 25 insertions(+), 15 deletions(-) > > diff --git a/update-conf.in b/update-conf.in > index 6a8ab16..da4208c 100644 > --- a/update-conf.in > +++ b/update-conf.in > @@ -10,14 +10,16 @@ init_tmpdir TMPD > LBUCACHE="$TMPD/lbucache" > > usage() { > - echo "$PROGRAM $VERSION > -Usage: $PROGAM [-aihl] > + cat >&2 << __EOF__ > +$PROGRAM $VERSION - TODO what is it? > +Usage: $PROGRAM [-a|--all] [-i|--initd] [-l|--list] [-h|--help] > +Options: > + -a, --all Select all updated files > + -i, --initd Use all new init.d scripts > + -l, --list List updated files > + -h, --help Show this help > > - -a Select all updated files. > - -h Show this help. > - -i Use all new init.d scripts. > - -l List updated files. > -" > +__EOF__ > } > > > @@ -31,15 +33,23 @@ is_initd() { > echo "$1" | grep etc/init.d/ > /dev/null > } > > -while getopts "alih" opt ; do > - case "$opt" in > - a) aflag="-a" ;; > - i) iflag="-i" ;; > - l) lflag="-l" ;; > - h|*) usage;; > - esac > +args=`getopt -o ailh --long all,initd,list,help -n "$PROGRAM" -- "$@"` I don't think this is posix shell compatible. We already use various extensions like 'local' and shell replace expansion ${var/search/replace} so we already depend on an extended shell. I think this is ok for now, but we should be aware of that this is moving away from posix shell compat. Is long options worth it? I also made a posix shell implementation for parsing options for lxc templates which we could use instead. -nc > +if [ $? -ne 0 ]; then > + usage > + exit 2 > +fi > +eval set -- "$args" > +while true; do > + case $1 in > + -a|--all) aflag="-a";; > + -i|--initd) iflag="-i";; > + -l|--list) lflag="-l";; > + -h|--help) usage; exit;; > + --) shift; break;; > + *) exit 1;; # getopt error > + esac > + shift > done > -shift `expr $OPTIND - 1` > > for apknew in $(find "$ROOT/etc" -name '*.apk-new') ; do > p="${apknew%.apk-new}" --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---