File: slurp.fqtest

package info (click to toggle)
fq 0.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 106,624 kB
  • sloc: xml: 2,835; makefile: 250; sh: 241; exp: 57; ansic: 21
file content (107 lines) | stat: -rw-r--r-- 2,451 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
$ 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
$ fq -d mp3 -i . test.mp3
mp3> .frames[0] | slurp("f")
mp3> $f[]
    |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.frames[0]{}: frame (mp3_frame)
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                                          |..              |
    |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x40|      49 6e 66 6f 00 00 00 0f 00 00 00 02 00 00|  Info..........|  tag{}: (mp3_frame_xing)
0x50|02 57 00 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6|.W..............|
*   |until 0xdd.7 (156)                             |                |
0xd0|                                          00 00|              ..|  audio_data: raw bits
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