Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Git grep command not interpreting flags correctly when an argument



ZSH doesn't perform word splitting by default, so `git grep $FLAGS pattern`
in ZSH is equivalent to `git grep "$FLAGS" pattern` in bash. You can
explicitly request word-slitting via `$=FLAGS`. There is also an option to
do this automatically but it's not a good idea to turn it on. Most of the
time you really don't want word splitting when you type $FOO.

Roman.

On Sun, May 19, 2019 at 8:10 PM Sam Houston <sehouston3@xxxxxxxxx> 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 error only seems to occur when I pass in with more than one `--` in the
> `FLAGS` variable.
>
> My `zsh --version` is `zsh 5.3 (x86_64-apple-darwin18.0)`.
>
> Let me know if I am doing something wrong, or if you need more information.
>
> Thanks,
>
> Sam
>


Messages sorted by: Reverse Date, Date, Thread, Author