Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Git grep command not interpreting flags correctly when an argument
- X-seq: zsh-workers 44329
- From: Sam Houston <sehouston3@xxxxxxxxx>
- To: Sam Houston <sehouston3@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Git grep command not interpreting flags correctly when an argument
- Date: Sun, 19 May 2019 20:42:22 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=o9NXp45ms4vq2SJIa43DYer3T/7TG0/8rXDkDXxRd28=; b=UMPE+or5BPL6pvrCWPMa4Znr6tv2pZo9/ilSVYFh2i/CgruMXzfuT+PTlAsLf+OqmA 8ANXrOGK9o+7Rtva2Ktn4BMwu8v//NJW7LZETMYZAdCDeKyRpTM6c7RG8NBr1nQ4hDBt Q4/zWniDMaI9hy5xysYEVy8GqcRAEQeTpLZJkhnGko4chfwvS4VODqKyMDM8TcjC30G2 S+El1UcHCKcFYpgRadUC/2Biwt639QDd9TpkOSXsekd1gAvwcGPEVu5AvrzGm1LEmgtS z97F2+RPyCqt94mfj1WJSnXAB8OoTrDsqfF42ePw3q9tObyiuG/hQjpuC7cT3PyvFa2L 0bvg==
- In-reply-to: <20190519183210.GA47046@CptOrmolo.darkstar>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CADbM1Mo6iqa=YcEFCw67FVOhZisX9ioBsdtzTcVmjEOgErebtA@mail.gmail.com> <20190519183210.GA47046@CptOrmolo.darkstar>
Very helpful Matthew, I've changed my implementation to use a zsh array.
Thanks to you both, I've solved my problem :)
On Sun, May 19, 2019 at 7:32 PM Matthew Martin <phy1729@xxxxxxxxx> wrote:
> On Sun, May 19, 2019 at 07:09:22PM +0100, Sam Houston wrote:
> > In a `bash` shell, in some empty directory, I can run the commands:
> >
> > ```bash
> > git init
> > echo "pattern" > file.txt
> > FLAGS="--untracked --color"
> > git grep $FLAGS pattern
> > ```
> >
> > And see the output:
> >
> > ```
> > file.txt:pattern
> > ```
> >
> > But in a `zsh` shell, when I run the same commands, I get the following
> > error:
> >
> > ```
> > error: unknown option `untracked --color'
> > ```
>
> The better way (both in zsh and in bash) would be to use an array.
>
> flags=(--untracked --color)
> git grep "${flags[@]}" pattern
> # git grep $flags pattern would also work, but just in zsh
>
> Relying on word splitting means that arguments that contain spaces or
> other IFS characters are mangled into two or more arguments.
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author