mirror of
https://github.com/wader/fq.git
synced 2024-12-25 22:34:14 +03:00
9e4f264193
Fixes missing function errors for fq builtins Add includes to fix some other missing function errors Add COMPLETION_TIMEOUT env to increase comepletion timeout during test using -race
47 lines
1.2 KiB
Plaintext
47 lines
1.2 KiB
Plaintext
include "internal";
|
|
include "binary";
|
|
include "decode";
|
|
|
|
def grep_by(f):
|
|
( ..
|
|
| select(f)?
|
|
);
|
|
|
|
def _value_grep_string_cond($v; $flags):
|
|
if type == "string" then test($v; $flags)
|
|
else false
|
|
end;
|
|
|
|
def _value_grep_other_cond($v; $flags):
|
|
. == $v;
|
|
|
|
def vgrep($v; $flags):
|
|
if $v | type == "string" then
|
|
grep_by(_is_scalar and _value_grep_string_cond($v; $flags))
|
|
else
|
|
grep_by(_is_scalar and _value_grep_other_cond($v; $flags))
|
|
end;
|
|
def vgrep($v): vgrep($v; "");
|
|
|
|
def _buf_grep_any_cond($v; $flags):
|
|
(isempty(tobytesrange | match($v; $flags)) | not)? // false;
|
|
def bgrep($v; $flags):
|
|
if $v | type == "string" then
|
|
grep_by(_is_scalar and _buf_grep_any_cond($v; $flags))
|
|
else
|
|
grep_by(_is_scalar and _buf_grep_any_cond($v; $flags))
|
|
end;
|
|
def bgrep($v): bgrep($v; "");
|
|
|
|
def grep($v; $flags):
|
|
if $v | type == "string" then
|
|
grep_by(_is_scalar and _buf_grep_any_cond($v; $flags) or _value_grep_string_cond($v; $flags))
|
|
else
|
|
grep_by(_is_scalar and _buf_grep_any_cond($v; $flags) or _value_grep_other_cond($v; $flags))
|
|
end;
|
|
def grep($v): grep($v; "");
|
|
|
|
def fgrep($v; $flags):
|
|
grep_by(_is_decode_value and (._name | test($v; $flags))? // false);
|
|
def fgrep($v): fgrep($v; "");
|