From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22554 invoked by alias); 31 Oct 2015 18:08:56 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37033 Received: (qmail 14170 invoked from network); 31 Oct 2015 18:08:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.0 Subject: Re: [PATCH] zed: fix argument parsing To: zsh-workers@zsh.org References: <1445968457-5930-1-git-send-email-llua@gmx.com> <1446000872-26311-1-git-send-email-llua@gmx.com> From: Eric Cook X-Enigmail-Draft-Status: N1110 Message-ID: <563503AB.3030200@gmx.com> Date: Sat, 31 Oct 2015 14:08:43 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1446000872-26311-1-git-send-email-llua@gmx.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:YnjdyO13kis7Wwm5JdPuARcX1V7bLR1XIZuppOOTwJ8HnQgpaEW Ql/XozD1rg60+w/owfqRaRyuQQaOyF40TLFm0tCZuj5tj3GCYVdWq5SJ5S8pmy63aeBPdN7 AoWM8s5O07QuVHJvNeHfjl0GWtmAbpLyD2OpkWiycuGmA7BYeiwUDWtptmw7dxlxUDxdVhT TvJ1x5vnIcZBQkm047iKg== X-UI-Out-Filterresults: notjunk:1;V01:K0:CATU7M8kZd0=:dJjP7cAiszb9hb1wgmOAww /ES0L9SpYS9CyEAwthORgyjF5xG/zR7Z49w0ATb743vqx1zWgoK1VM1jWpdqyzedhTlXK46P6 ICbd64B2fcX2bC7jZqCUcZleYUcqDcDzx/w2T51bVgLhgjsXntfmobI3w90QXraJj1kmV3lLd Cjto+UX+j86DFqgh+DR91pJvZ2OxbwAQWp9xU55YP/o4r3SbuDA5SmQf3HsZ+prKAfUNw1Lpw lElxvtuLL22IN8nNEzkRMNIddLWUT76XxBLinF1tlP5Sg/o9ih13yAjlZ/8ab6zsQGzpXETqa g0TDC4Ua2jsOtn1641IEzeQCxeN5YvW70vgNmWat7pUOU86xYJLnAnWWvWdoKFTU5xJbniu9x tJseVzZaa7REF9X4NgEG6gVWQDivE7iVmv2/9w7rsZg9Nb18qpmGFiRiOYF+UmFbuRJHHyMUw /tSZZWHJO9PzpKTZWzmd3EyORhUJNoCTRoZ7Hevy71EfbrX8zhSqAKCRB0zylogExXqQ30fpL nmPXIQYBWSjKHpi8zp86bV59EaaFFgFBIkYPwtcXww/TWxLpUFbJfDWDVLoekeSWr6bdP51Mp C+i0Lgll1OAVrR+q+xj2rDBTS5/dUuJ+0XNx4K94ZfdFKIS9CYJPv3mgf2xUV+ivnr0n4z8if Ai13Jzkb38ZzEjnLRJUDPI7Yz7SuURGhUfiWMLGd//doWg0rcus+FK7Sjop0Q4E1GSAWXFF+5 bfl25+yho0Ttn+Ott7j7d1F0O2NC+gF5rJWdVKwADRevILkvN6io287mQ4TBsU/1sOV3lUTUh ClDTBw2 On 10/27/2015 10:54 PM, Eric Cook wrote: > Also reported in IRC: > > % fned +vi-git-applied-string > zed:4: bad option: -v > zed:4: bad option: -i > zed:4: bad option: -- > zed:4: bad option: -g > ... > > This could optionally be fixed by changing getopts "fbx:" to > getopts ":fbx:" so the `unknown options' are silently ignored. :/ that patch allows `zed -foo' to edit the function `-foo'. It should error due to unknown options in my opinion. I think editing files/functions that start with `+' or `-' should require -- to be used. This patch silents the bad options errors, shown in my first example and zed will show the help message. To edit the function `+vi-git-applied-string', `--' is needed. diff --git a/Functions/Misc/zed b/Functions/Misc/zed index 1f6042e..2c957ba 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -11,7 +11,7 @@ local var opt zed_file_name integer TMOUT=0 okargs=1 fun bind local -a expand -while getopts "fbx:" opt; do +while getopts ":fbx:" opt; do case $opt in (f) fun=1