33 lines
598 B
Text
33 lines
598 B
Text
|
#!/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
|