From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Zsh Workers <zsh-workers@sunsite.dk>
Subject: Re: Potential improvement for zmv
Date: Thu, 28 Mar 2002 15:59:14 +0000 [thread overview]
Message-ID: <1020328155914.ZM1111@candle.brasslantern.com> (raw)
In-Reply-To: <Pine.LNX.4.33L2.0203271609001.11438-100000@phong.blorf.net>
On Mar 27, 4:48pm, Wayne Davison wrote:
} Subject: Potential improvement for zmv
}
} I implemented a new option for zmv: -W. This works just like -w, with
} the additional feature that it automatically transforms wildcards in the
} replacement pattern into a sequential series of ${1} .. ${N} vars.
}
} Here's the patch. Let me know what you think.
My only concern is that it should complain if the number of wildcards in
the destination is less than the number of wildcards in the source. Else
you're likely to lose the rightmost patterns from the source, which are
probably the most important (the file name itself).
} Since I'm still a novice shell programmer, some of you wizards out
} there can undoubtedly improve the shell code I wrote. For instance,
} I don't know if it's possible to increment $N inside a global search
} and replace (I resorted to using a loop).
You can just about do it:
integer N=0
x=(x x x x x x)
print ${(e)x//x/\$[++N]}
but the escaping to wrap each $[++N] in ${...} gets a bit arcane.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
next prev parent reply other threads:[~2002-03-28 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-28 0:48 Wayne Davison
2002-03-28 15:59 ` Bart Schaefer [this message]
2002-03-29 1:12 ` PATCH: -W option for zmv (updated) Wayne Davison
2002-03-29 2:38 ` Bart Schaefer
2002-03-29 5:32 ` Wayne Davison
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=1020328155914.ZM1111@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@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).