Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Ex-bash script for optimisation
- X-seq: zsh-users 8580
- From: zzapper <david@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Ex-bash script for optimisation
- Date: Fri, 11 Mar 2005 09:04:53 +0000
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <62u0315opl6kubat89fmdng5dg4m4370o0@xxxxxxx> <42308ED6.6030007@xxxxxxx> <1050311044847.ZM9336@xxxxxxxxxxxxxxxxxxxxxxx>
- Sender: news <news@xxxxxxxxxxxxx>
On Fri, 11 Mar 2005 04:48:46 +0000, wrote:
>Comments on script style:
>
>None of the variables is declared (with "declare" or "local") so this is
>probably not suitable for use as an autoloaded shell function.
>
>"filebad" is set but not used, and there's no reason to use "let" syntax
>if you're not doing arithmetic (in the assignment of 1 to filebad).
>
>On Mar 10, 4:43pm, zzapper wrote:
>} Subject: Ex-bash script for optimisation
>}
>} Q1) Is there a better way to generate the array filelst
>
>Sure. You don't need the loop, just do a glob with an extended pattern.
>
>#--- snip ---
>setopt local_options extended_glob null_glob
>filelst=( *$1*~*.(aux|toc|dvi|aux|exe|obj|zip|pdf|mdb|xls|bak|swp|log|jpg|gif|tiff|jpeg|bmp) )
>#--- snip ---
>
>If you want to allow $1 to be a pattern rather than a fixed string, you
>need *${~1}* instead.
>
>If you want to allow multiple arguments to the script, you need *${^*}*
>or for multiple patterns *${^~*}*
>
>In the event that you really need to loop, zsh 4.2+ supports array append
>with the syntax: filelst+=($x)
>
>} Q2) the line "for x in *$1*" fails is no match, how can i "catch" this
>
>Peter Miller's *$1*(N) suggestion is equivalent to the "null_glob"
>setting in my example above.
Oh gosh!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author