zed icon indicating copy to clipboard operation
zed copied to clipboard

Passing regexp or glob into a User Op

Open philrz opened this issue 2 years ago • 0 comments

These don't currently work.

$ echo '"foo" "bar" "baz"' | zq -Z 'op foo(pattern): ( grep(pattern) ) foo(*a*)' -
zq: error parsing Zed at column 40:
op foo(pattern): ( grep(pattern) ) foo(*a*)
                                   === ^ ===

$ echo '"foo" "bar" "baz"' | zq -Z 'op foo(pattern): ( grep(pattern) ) foo(/a/)' -
zq: error parsing Zed at column 40:
op foo(pattern): ( grep(pattern) ) foo(/a/)
                                   === ^ ===

Details

Repro is with Zed commit 40739bd.

This was discussed in the context of #4692 where it became possible to pass a string into a User Op and then use that as an argument to grep(). So this works now where it didn't before:

$ zq -version
Version: v1.11.1-16-g40739bdc

$ echo '"foo" "bar" "baz"' | zq -Z 'op foo(pattern): ( grep(pattern) ) foo("bar")' -
"bar"

However, the glob and regexp variations shown in the opening tl;dr text above still don't work yet. I recently got @mccanne on-record saying we should probably make them work at some point, hence this issue. 😉

philrz avatar Dec 01 '23 01:12 philrz