zsh-users
 help / color / mirror / code / Atom feed
From: zzapper <david@tvis.co.uk>
To: zsh-users@sunsite.dk
Subject: Re: Ex-bash script for optimisation
Date: Fri, 11 Mar 2005 09:04:53 +0000	[thread overview]
Message-ID: <ndn2319a50r5t6tf2j7rgf4k84pgb5caa6@4ax.com> (raw)
In-Reply-To: <1050311044847.ZM9336@candle.brasslantern.com>

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!



  reply	other threads:[~2005-03-11  9:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-10 16:43 zzapper
2005-03-10 18:15 ` Peter Miller
2005-03-11  4:48   ` Bart Schaefer
2005-03-11  9:04     ` zzapper [this message]
2005-03-13 18:46     ` zzapper
2005-03-13 19:23       ` Bart Schaefer
2005-03-10 18:42 Meino Christian Cramer
2005-03-11  5:14 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ndn2319a50r5t6tf2j7rgf4k84pgb5caa6@4ax.com \
    --to=david@tvis.co.uk \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).