From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: Zsh-workers <zsh-workers@sunsite.dk>
Subject: Re: Regexp replace on all arguments.
Date: Sat, 11 Feb 2006 17:38:19 +0000 [thread overview]
Message-ID: <20060211173818.GA4965@sc> (raw)
In-Reply-To: <20060211173626.GA6863@lxlabs.com>
On Sat, Feb 11, 2006 at 11:06:26PM +0530, Ligesh wrote:
>
> Hi folks,
>
> I want to replace all occurrences of say '/c/' in the arguments with 'c:'. Could someone help me with completing the function below.
>
> winexec () {
>
> // First loop through all arguments and replace
>
> foreach arguments $2 to $- {
> replace ^/c/ with c: , ^/d/ with d: etc. (The character c, d should be preserved, '^' means beginning of the word.)
> }
>
> execute $1 with the new arguments.
>
> }
>
> The execution would be
>
> $ winexec cacls.exe /c/name-of-file
[...]
winexec() {
local cmd=$1
shift || return
argv=("${@//#\/(#b)([a-zA-Z])\//$match:}")
"$cmd" "$@"
}
--
Stéphane
next prev parent reply other threads:[~2006-02-11 17:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-11 17:36 Ligesh
2006-02-11 17:38 ` Stephane Chazelas [this message]
2006-02-11 18:21 ` Ligesh
2006-02-11 19:20 ` 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=20060211173818.GA4965@sc \
--to=stephane_chazelas@yahoo.fr \
--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).