execline-json/json-split-entries

33 lines
598 B
Text
Raw Permalink Normal View History

2022-08-05 20:47:29 +00:00
#!/bin/execlineb
pipeline { sed "s/./\\0\\n/g" }
init-state level
save-state level 0
foreground {
forstdin -E char
case "$char" {
"(\\{|\\[)" {
load-state level cur
backtick -I -E new { s6-expr "$cur" + 1 }
save-state level $new
s6-echo -n "$char"
}
"(\\}|\\])" {
load-state level cur
backtick -I -E new { s6-expr "$cur" - 1 }
save-state level $new
s6-echo -n "$char"
}
"," {
load-state level cur
save-state level "$cur"
ifelse { s6-test "$cur" = 0 } {
s6-echo
}
s6-echo -n "$char"
}
}
s6-echo -n "$char"
}
s6-echo