From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27684 invoked from network); 16 Dec 2021 02:00:36 -0000 Received: from tb-ob0.topicbox.com (64.147.108.117) by inbox.vuxu.org with ESMTPUTF8; 16 Dec 2021 02:00:36 -0000 Received: from tb-mx1.topicbox.com (tb-mx1.nyi.icgroup.com [10.90.30.61]) by tb-ob0.topicbox.com (Postfix) with ESMTP id CFF4A3187A for ; Wed, 15 Dec 2021 21:00:34 -0500 (EST) (envelope-from bounce.mM9d1884360382f65d1acf8c9d.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx1.topicbox.com (Postfix, from userid 1132) id C57E2AF42E3; Wed, 15 Dec 2021 21:00:34 -0500 (EST) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=pu5Zs2jq header.a=rsa-sha256 header.s=20210112 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; spf=pass smtp.mailfrom=karisawa@gmail.com smtp.helo=mail-pl1-f176.google.com; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=message-id:date:mime-version:to:from :content-type:content-transfer-encoding:list-help:list-id :list-post:list-subscribe:reply-to:subject:list-unsubscribe; s= sysmsg-1; t=1639620034; bh=XRTwKQ4tJFzwzY3W87pFaZqYYmUCfoWzVFGdb upn83U=; b=H/HPzrNZQrcEevX3MwXmJX+KkhSQr2Pj09AFf3eIXn+UF04HIMg8O 2qCOBavUYCG7ZIfbGKBAAmb1dixKeoJQ5NUFI7lPizct3f8xkEE/mlTSmf7Jd1T3 bVWHgFOFSiJiU63QdOcfibo1Z+28eADdBuRcYTJwtSyirNTWLM/CGQ= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1639620034; b=hicF+fkA6hP9RWHK5agc7rDvpQc7aPAHBRkouOA7j4vIcewFwe +eBvu7+BBwsAlPWobszL+eO1uBHZtRcZRyrtQDxghHi2npaysHizLkn/zz+tkVsI 99Uq5p9aG5m9HeZRMTWgfvcGL1miVCW8tOf3N5yfYV/isTkaooTqqbv/Y= Authentication-Results: topicbox.com; arc=pass; dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=pu5Zs2jq header.a=rsa-sha256 header.s=20210112 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; spf=pass smtp.mailfrom=karisawa@gmail.com smtp.helo=mail-pl1-f176.google.com; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=pu5Zs2jq header.a=rsa-sha256 header.s=20210112 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; iprev=pass smtp.remote-ip=209.85.214.176 (mail-pl1-f176.google.com); spf=pass smtp.mailfrom=karisawa@gmail.com smtp.helo=mail-pl1-f176.google.com; x-aligned-from=pass (Address match); x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=8DdIYlVs; x-me-sender=none; x-ptr=pass smtp.helo=mail-pl1-f176.google.com policy.ptr=mail-pl1-f176.google.com; x-return-mx=pass header.domain=gmail.com policy.is_org=yes (MX Records found: alt3.gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt4.gmail-smtp-in.l.google.com); x-return-mx=pass smtp.domain=gmail.com policy.is_org=yes (MX Records found: alt3.gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt4.gmail-smtp-in.l.google.com); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=message-id :date:mime-version:to:from:content-type :content-transfer-encoding:list-help:list-id:list-post :list-subscribe:reply-to:subject:list-unsubscribe; s=dkim-1; bh= XRTwKQ4tJFzwzY3W87pFaZqYYmUCfoWzVFGdbupn83U=; b=cn6Iuq8e4eZy9Fkh 5xOrCHyG79474iszT99vXKHIymF2pDZzb4UjueG0nUX9tn/A2PDEHKyyZlZmojhd /vsYlAhw2rTpcdLU81y7e+ofVps+aw01B/Z4GXk14S7DQrJhXb7wmeez0FzxwMbz YPbJDs+jYOEc2Krzm1fB0rq5FNk= Received: from tb-mx0.topicbox.com (localhost.local [127.0.0.1]) by tb-mx0.topicbox.com (Postfix) with ESMTP id EE4F3BF61E2 for <9fans@9fans.net>; Wed, 15 Dec 2021 20:59:57 -0500 (EST) (envelope-from karisawa@gmail.com) Received: from tb-mx0.topicbox.com (localhost [127.0.0.1]) by tb-mx0.topicbox.com (Authentication Milter) with ESMTP id 5242B7DC5E8; Wed, 15 Dec 2021 20:59:57 -0500 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1639619997; b=uvgC0YmA8ddsZESezXA0uGGHjjVmjKsqR039umrKVqIsJ6rVJi D7zjtC++i27eKSLh/vYFwu/kREsxCy9IYCs8P2cPdkXzez5GERKuqmikpEvjcJi6 Pyx530zYh26Lk2KCh50T0QtcKB/ca26lcQMx+40PCBwYsWbHVISKo6wsG3wfhPPA 3fe25EzW+xwzW57gAmUEywlrsSRWWqNCpt4LmDFXFPWu6g0g9WWa5B11x21TDITW 9A0Uu/AZXf45qj5vPR9TkfNjgV/OYTb+EIzNhIXmE5pqLNct5r2+qMKqjBW04YwC jQ9TXgaJfPAiuA4hxLnnPdmpetucox/jVmCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=message-id:date:mime-version:to:from:subject :content-type:content-transfer-encoding; s=arcseal; t= 1639619997; bh=7InmzPEVTZAQ4ocG37zYMKxCRwem897rRoFRApy3EYU=; b=t FNOOFo1lAzHpLA5qDgLYufXzqRIngoSBqyhnW2B94pMhkccmyOj96R6r1QTsqf/4 tuwgIol41dQWU4NjO0FIOFhefv7q8Fbxn6mkvG37xTBtprd8gynbMy+wjaRb17fb hOdcK8d+zCAQdE2gdPaxF3lNHRSE8I36EIa6h99QrDOe0X9rXnDHQXdWUggOY8pJ nfohHe+I8ERQp4mPatb4KPh4qB5QNo/pQPnXidzqf37I6rvfeQYWQ7CU/4toHGyy AHAjEhGuV+M4ULXG7BG4XVrQvBfnM62THfthT8JSgvmNRkBn6LxqRirKogHw4xD7 rD6oO3326o7RoKZ+5Qtng== ARC-Authentication-Results: i=1; tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=pu5Zs2jq header.a=rsa-sha256 header.s=20210112 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; iprev=pass smtp.remote-ip=209.85.214.176 (mail-pl1-f176.google.com); spf=pass smtp.mailfrom=karisawa@gmail.com smtp.helo=mail-pl1-f176.google.com; x-aligned-from=pass (Address match); x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=8DdIYlVs; x-me-sender=none; x-ptr=pass smtp.helo=mail-pl1-f176.google.com policy.ptr=mail-pl1-f176.google.com; x-return-mx=pass header.domain=gmail.com policy.is_org=yes (MX Records found: alt3.gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt4.gmail-smtp-in.l.google.com); x-return-mx=pass smtp.domain=gmail.com policy.is_org=yes (MX Records found: alt3.gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt4.gmail-smtp-in.l.google.com); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvuddrledvgdeludculddtuddrgeduhedrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghn shhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtne cunecujfgurhepkfffgggfvffhufgtgfesthekredttdefjeenucfhrhhomhepnjjnucjn njcuoehkrghrihhsrgifrgesghhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhepff fgteehgfelgfefffeuhfevgedtieegieevkeejhfevfffffeetieefgeegvdejnecukfhp pedvtdelrdekhedrvddugedrudejiedpvdegtddvmeeisgdttdemjegvjegrmeeivddttd emugeljeeimehflegugeemudelledumegvtdefleenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepihhnvghtpedvtdelrdekhedrvddugedrudejiedphhgvlhhopehmrg hilhdqphhluddqfhdujeeirdhgohhoghhlvgdrtghomhdpmhgrihhlfhhrohhmpeeokhgr rhhishgrfigrsehgmhgrihhlrdgtohhmqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (gmail.com ... _spf.google.com: Sender is authorized to use 'karisawa@gmail.com' in 'mfrom' identity (mechanism 'include:_netblocks.google.com' matched)) receiver=tb-mx0.topicbox.com; identity=mailfrom; envelope-from="karisawa@gmail.com"; helo=mail-pl1-f176.google.com; client-ip=209.85.214.176 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx0.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Wed, 15 Dec 2021 20:59:57 -0500 (EST) (envelope-from karisawa@gmail.com) Received: by mail-pl1-f176.google.com with SMTP id y7so18201933plp.0 for <9fans@9fans.net>; Wed, 15 Dec 2021 17:59:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:to :content-language:from:subject:content-transfer-encoding; bh=7InmzPEVTZAQ4ocG37zYMKxCRwem897rRoFRApy3EYU=; b=8DdIYlVsw4v7Pdpsp9QHPiCaumT4HHc/Reqz7mE64rnNCVNTSg0DwpU1US0FhK45do Ds1MplvLMHp9sEkXyDGXf+oY5e6Yw3uU/MdbcVIxjRWkmpSbVIm0shgHkGURPW7teJH4 Xanf9d8cPYZVVzR/qMrVrlZZfvBYcm7p6mQLQs0X433Trk4TPNzqXqs76OwTu8x0Cd2a lDL8jNaLHP3o8MDhzV7bgBYdK+8yjWhgGoNJ9GLQA65GYhgU5lGZtrNT6Y885yprSXcc +JNtnoiJ8jx3mNUZYOY80g1j0aAjxwtB4LQHdHVtt9bNtOTkhcPYzLcLlXhkqeNtPJPq YCOQ== X-Gm-Message-State: AOAM531K+rtuh5Ju/cR+J0t8b8HrBCdYUOVWP30FgbnsjZmDHIOlTAK/ CLxIc6IsRHrxZ1SEQ54sYFxm0MvfV1I= X-Google-Smtp-Source: ABdhPJwmhS2Uq6TRn/mtEKGzwJ+9nwX/X+SogsOU00BPFm9menJQDwZMpNnhvEkYepTJtVZwJzJCBg== X-Received: by 2002:a17:902:7289:b0:142:805f:e2c with SMTP id d9-20020a170902728900b00142805f0e2cmr13755325pll.42.1639619996270; Wed, 15 Dec 2021 17:59:56 -0800 (PST) Received: from ?IPV6:2402:6b00:7e7a:6200:d976:f9d4:1991:e039? ([2402:6b00:7e7a:6200:d976:f9d4:1991:e039]) by smtp.gmail.com with ESMTPSA id m3sm3375158pgj.25.2021.12.15.17.59.55 for <9fans@9fans.net> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Dec 2021 17:59:55 -0800 (PST) Message-ID: <30a162f6-6431-a003-83c1-4f90f71000fc@gmail.com> Date: Thu, 16 Dec 2021 10:59:53 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 To: 9fans@9fans.net Content-Language: en-US From: =?UTF-8?B?5pyJ5r6kIOWBpeayuw==?= Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: e6d870e8-5e13-11ec-8783-8423f2255d03 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UMGNlYjVkZDcwOGViZmQ0Zi1NOWQxODg0MzYwMzgyZjY1ZDFhY2Y4?= =?UTF-8?B?YzlkPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Subject: [9fans] decomp for rc script List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:M9d1884360382f65d1acf8c9d:1:QLQQ-hlWAvHMDD5ZVjYpCZeVlvSvgeR4ghGzsujzzpM Hello 9fans. Plan9 C has nice ARGBEGIN and ARGEND macros, which make easy to write=20 code for flags and options. For example composed flag style =C2=A0=C2=A0 =C2=A0ls -pld dir is OK. We are not insisted to write decomposed flag style: =C2=A0=C2=A0 =C2=A0ls -p -l -d dir In rc code, we write code such as while(~ $1 -*){ =C2=A0=C2=A0 =C2=A0switch($1){ =C2=A0=C2=A0 =C2=A0case -a =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0aopt=3D$2 =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0shift =C2=A0=C2=A0 =C2=A0case -b =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bflag=3D1 =C2=A0=C2=A0 =C2=A0... assuming decomposed flags and options. I sometimes make mistakes in executing commands forgetting they are=20 coded in rc. I want uniform handling for flags and options in command line. A small helper tool named "decomp" may be useful for this purpose. =3D=3D=3D BEGIN =3D=3D=3D #!/bin/awk -f # decomp is designed to make easy to parse # flags and options in rc script. # usage: echo flg:opt $* | decomp # examples: # =C2=A0=C2=A0 % echo abc:de -cadefg| decomp # =C2=A0=C2=A0=C2=A0 -c -a -d efg #=C2=A0=C2=A0=C2=A0 % echo abc:de -caxbcdefg| decomp # =C2=A0=C2=A0=C2=A0 -c -a# error in x=C2=A0=C2=A0=C2=A0 (-caxbcdefg) #=C2=A0=C2=A0 =C2=A0% echo abc:de -cabcdefg xyz| decomp #=C2=A0=C2=A0 =C2=A0 -c -a -b -c -d efg xyz #=C2=A0=C2=A0 =C2=A0% echo abc:de -cabxcdefg -axy | decomp #=C2=A0=C2=A0 =C2=A0 -c -a -b# error in x=C2=A0=C2=A0 =C2=A0(-cabxcdefg) #=C2=A0=C2=A0 =C2=A0% echo abc:de -cabcd efg -a xy | decomp #=C2=A0=C2=A0 =C2=A0 -c -a -b -c -d efg -a xy #=C2=A0=C2=A0 =C2=A0% echo abc: -cabcdefg | decomp #=C2=A0=C2=A0 =C2=A0 -c -a -b -c# error in d=C2=A0=C2=A0 =C2=A0(-cabcdefg) #=C2=A0=C2=A0 =C2=A0% echo :de -cabxcdefg | decomp #=C2=A0=C2=A0 =C2=A0# error in c=C2=A0=C2=A0 =C2=A0(-cabxcdefg) #=C2=A0=C2=A0 =C2=A0% echo abc: -a - foo | decomp #=C2=A0=C2=A0 =C2=A0 -a - foo #=C2=A0=C2=A0 =C2=A0% echo abc: -a - 'f oo' | decomp #=C2=A0=C2=A0 =C2=A0 -a - f oo #=C2=A0=C2=A0 =C2=A0BUG: decomp cannot handle spaces in arguments # # 2021/12/14 Kenar # function definitions are first function error(fmt,s){ =C2=A0=C2=A0 =C2=A0printf(fmt,s) > "/dev/cons" =C2=A0=C2=A0 =C2=A0exit "usage" } function isplit(s,n){ =C2=A0=C2=A0 =C2=A0return substr(s,1,n-1) " " substr(s,n) } function decomp1(s,s0,b,c,t){ =C2=A0=C2=A0 =C2=A0# then s,s0,b,c,t are local =C2=A0=C2=A0 =C2=A0if(cont){ =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0printf(" %s", s) =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0cont =3D 0 =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return =C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0 =C2=A0cont =3D 0 =C2=A0=C2=A0 =C2=A0s0 =3D s =C2=A0=C2=A0 =C2=A0for(;;){ =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0#print "#1", s =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0split(isplit(s,2),t," ") =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0b=3Dt[1] =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0c=3Dt[2] =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0#print "#2", b, c =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if(b !=3D "-"){ =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0printf(" %s", s) =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0split(isplit(c,2),t," ") =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0b=3Dt[1] =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0c=3Dt[2] =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0#print "#3", b, c =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if(index(opt,b) !=3D 0){ =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if(c =3D=3D ""){ =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0printf(" -%s", b) =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0cont =3D 1 =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0else =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0printf(" -%s %s", b, c) =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if(index(flg,b) !=3D 0){ =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0printf(" -%s", b) =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if(c =3D=3D "") =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0return =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0s =3D "-" c =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0continue =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0error(fmt1, b "\t(" s0 ")") =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return =C2=A0=C2=A0 =C2=A0} } BEGIN{ # global constants are here, not insisted by awk though =C2=A0=C2=A0 =C2=A0fmt1=3D"# error in %s\n" =C2=A0=C2=A0 =C2=A0fmt2=3D"# error in input line:\n#\t%s\n"\ =C2=A0=C2=A0 =C2=A0"# required flg:opt at the first argument\n" } { =C2=A0=C2=A0 =C2=A0if((m =3D split($0,u," ")) < 2 || split(u[1],t,":") != =3D 2) =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0error(fmt2,$0) =C2=A0=C2=A0 =C2=A0flg =3Dt[1] =C2=A0=C2=A0 =C2=A0opt =3Dt[2] =C2=A0=C2=A0 =C2=A0cont =3D 0 =C2=A0=C2=A0 =C2=A0#print "#", flg, opt =C2=A0=C2=A0 =C2=A0for(n =3D 2; n <=3D m; n++){ =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0#print "#", u[n] =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0decomp1(u[n]) =C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0 =C2=A0# Why the code below doesn't work? =C2=A0=C2=A0 =C2=A0# split("abc de",u," ") =C2=A0=C2=A0 =C2=A0# for(a in u){ =C2=A0=C2=A0 =C2=A0#=C2=A0=C2=A0 =C2=A0print a=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0# a is ? =C2=A0=C2=A0 =C2=A0# } =C2=A0=C2=A0 =C2=A0# not required but maybe better in debugging =C2=A0=C2=A0 =C2=A0printf("\n") } =3D=3D=3D END =3D=3D=3D Then adding lines =C2=A0=C2=A0 =C2=A0*=3D`{echo flg:opt $* | decomp} =C2=A0=C2=A0 =C2=A0if(~ $status ?*) {do something} before "while(~ $1 -*)" enables composed flags and options like C. Maybe someone already have a tool of this sort, or "decomp" may be improved to be better one, or there are more bugs in it, then information is welcome. Kenji Arisawa ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T0ceb5dd708ebfd4f-M9d188= 4360382f65d1acf8c9d Delivery options: https://9fans.topicbox.com/groups/9fans/subscription