[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Grep pattern from files
From: |
michael-franzese |
Subject: |
Re: Grep pattern from files |
Date: |
Thu, 22 Apr 2021 22:31:50 +0200 |
> Sent: Friday, April 23, 2021 at 8:26 AM
> From: "Greg Wooledge" <greg@wooledge.org>
> To: help-bash@gnu.org
> Subject: Re: Grep pattern from files
>
> On Thu, Apr 22, 2021 at 09:56:22PM +0200, michael-franzese@gmx.com wrote:
> > grepot ()
> > {
> > grep --include="*.org" --include="*.texi" -hir "${1}" "$@:2"
> > }
> >
> > But testing it with
> >
> > grepot --include="*.el" "-C 8 ddd ./"
>
> In your previous message, you said you designed your function to require
> three arguments: a number, a pattern, and a directory.
Yes, the number was intended to be used for the hardwired -C option.
Then did some more work on it, so I cound pass the option directly.
> However, this is
> not what you passed to it. You passed two arguments, the first being
> something that looks like an option, and the second being a concatenation
> of another option-looking thing, a number, a pattern, and a directory.
>
> You appear to be over-complicating everything, and quoting incorrectly.
> Why not just write it like a wrapper:
>
> grepot() {
> grep --include="*.org" --include="*.texi" -hir "$@"
> }
>
> Then you can pass whatever options and arguments you like to it:
>
> grepot --include="*.el" -C 8 ddd ./
I agree, I could have complicated things.