-
Notifications
You must be signed in to change notification settings - Fork 0
/
test3.sh
executable file
·55 lines (46 loc) · 1.08 KB
/
test3.sh
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
#!/bin/sh
. ./lib/jq_stack3.lib.sh
#. ./lib/jq_stack3_modcall.lib.sh
#. ./lib/jq_stack3_modload.lib.sh
#. ./lib/jq_stack3_oneline.lib.sh
export JQ_STACK3_MODDIR="../jsondiff/lib"
#jq -rc '["jq", .option, (.functiondef + .call)]|@sh'
#jqmod2jqargs() {
# jq -rc '
# [
# "jq",
# .option,
# ( (.functiondef|join("\n")) + .call )
# ]|@sh'
#}
test2a() {
jq_stack3 init
{
echo '{"option": "-c"}'
echo '{"name":"sortallarrays"}'
echo '{"function": '"$(jq -cR . < test2-function-jq.def | jq -s .)"'}'
echo '{"modload": "sortallarrays"}'
echo '{"call":".|sortallarrays|."}'
} > "$JQ_STACK3_TMP"
jq_stack3 run
jq_stack3 deinit
}
test1a() {
jq_stack3 init
jq_stack3 option -c
jq_stack3 modload sortallarrays call '.|sortallarrays|.'
#jq_stack3 cat
#jq_stack3 gen
jq_stack3 run
jq_stack3 deinit
}
#test2b() {
# jq_stack3 oneline -c sortallarrays: '.|sortallarrays|.'
#}
checktest() {
read result;
[ "$result" = '["1","2","3"]' ] && echo ok || echo fail
}
echo '["3", "1", "2"]' | test2a | checktest
#echo '["3", "1", "2"]' | test2b | checktest
echo '["3", "1", "2"]' | test1a | checktest