Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Regexp replace on all arguments.
- X-seq: zsh-workers 22226
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Zsh-workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: Regexp replace on all arguments.
- Date: Sat, 11 Feb 2006 17:38:19 +0000
- In-reply-to: <20060211173626.GA6863@xxxxxxxxxx>
- Mail-followup-to: Zsh-workers <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20060211173626.GA6863@xxxxxxxxxx>
- Sender: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author