Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Ex-bash script for optimisation



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