2022-02-21 00:25:46 +03:00
|
|
|
$ fq -ni
|
|
|
|
null> abc | slurp
|
|
|
|
error: expr: slurp requires one string argument. ex: ... | slurp("name")
|
|
|
|
null> slurp | 1
|
|
|
|
error: slurp must be last in pipeline. ex: ... | slurp("name")
|
|
|
|
null> abc | slurp("a")
|
|
|
|
error: expr: function not defined: abc/0
|
|
|
|
null> "a"+1 | slurp("a")
|
|
|
|
error: cannot add: string ("a") and number (1)
|
|
|
|
null> 123 | slurp("a")
|
|
|
|
null> 123, "bb" | slurp("bb")
|
|
|
|
null> 123, 456, error("err"), "bb" | slurp("err")
|
|
|
|
error: err
|
|
|
|
null> spew
|
|
|
|
{
|
|
|
|
"a": [
|
|
|
|
123
|
|
|
|
],
|
|
|
|
"bb": [
|
|
|
|
123,
|
|
|
|
"bb"
|
|
|
|
],
|
|
|
|
"err": [
|
|
|
|
123,
|
|
|
|
456
|
|
|
|
]
|
|
|
|
}
|
|
|
|
null> spew("bb")
|
|
|
|
123
|
|
|
|
"bb"
|
|
|
|
null> $a
|
|
|
|
[
|
|
|
|
123
|
|
|
|
]
|
|
|
|
null> "aa" | slurp("a")
|
|
|
|
null> spew
|
|
|
|
{
|
|
|
|
"a": [
|
|
|
|
"aa"
|
|
|
|
],
|
|
|
|
"bb": [
|
|
|
|
123,
|
|
|
|
"bb"
|
|
|
|
],
|
|
|
|
"err": [
|
|
|
|
123,
|
|
|
|
456
|
|
|
|
]
|
|
|
|
}
|
|
|
|
null> $a
|
|
|
|
[
|
|
|
|
"aa"
|
|
|
|
]
|
|
|
|
null> . | repl
|
|
|
|
> null> $bb
|
|
|
|
[
|
|
|
|
123,
|
|
|
|
"bb"
|
|
|
|
]
|
|
|
|
> null> ^D
|
|
|
|
null> 123 | slurp("a b")
|
|
|
|
error: expr: invalid slurp name "a b", must be a valid identifier. ex: ... | slurp("name")
|
|
|
|
null> 123 | slurp(null)
|
|
|
|
error: expr: invalid slurp name "null", must be a valid identifier. ex: ... | slurp("name")
|
|
|
|
null> ^D
|
|
|
|
$ fq -i
|
|
|
|
null> 1,2,3 | repl
|
|
|
|
> number, ...[0:3][]> ., .*2 | slurp("b")
|
|
|
|
> number, ...[0:3][]> if . == 2 then error("err") end | slurp("c")
|
|
|
|
error: err
|
|
|
|
> number, ...[0:3][]> ^D
|
|
|
|
null> spew
|
|
|
|
{
|
|
|
|
"b": [
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
4,
|
|
|
|
3,
|
|
|
|
6
|
|
|
|
],
|
|
|
|
"c": [
|
|
|
|
1,
|
|
|
|
3
|
|
|
|
]
|
|
|
|
}
|
|
|
|
null> ^D
|
2022-05-21 20:33:52 +03:00
|
|
|
$ fq -d mp3 -i . test.mp3
|
2022-02-21 00:25:46 +03:00
|
|
|
mp3> .frames[0] | slurp("f")
|
|
|
|
mp3> $f[]
|
2022-05-20 13:38:43 +03:00
|
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.frames[0]{}: frame (mp3_frame)
|
2022-02-21 00:25:46 +03:00
|
|
|
0x20| ff fb 40| ..@| header{}:
|
|
|
|
0x30|c0 |. |
|
|
|
|
0x30| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00| ...............| side_info{}:
|
|
|
|
0x40|00 00 |.. |
|
2022-08-09 15:27:59 +03:00
|
|
|
0x40|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| xing{}: (xing)
|
2022-02-21 00:25:46 +03:00
|
|
|
0x50|02 57 00 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6|.W..............|
|
|
|
|
* |until 0xdd.7 (156) | |
|
2022-08-17 17:09:36 +03:00
|
|
|
0xd0| 00 00| ..| audio_data: raw bits
|
2022-02-21 00:25:46 +03:00
|
|
|
0xe0|00 00 00 |... |
|
|
|
|
| | | crc_calculated: "827a" (raw bits)
|
|
|
|
mp3> ^D
|
|
|
|
$ fq -n slurp
|
|
|
|
exitcode: 3
|
|
|
|
stderr:
|
|
|
|
error: arg: slurp can only be used from interactive repl
|