1 #S="\$(asda\$(s\$(g)), \$(z))sd \$(asds \$(asd))dsa"
2 #S="\$(asda\$(s\$(g)), \$(z))sd \$(asds \$(asd))"
3 #S="asd \$(asda\$(s\$(g)), \$(z))sd \$(asds \$(asd))dsa"
4 S
="asd \$(asda\$(s\$(g)), \$(z))sd \$(asds \$(asd))"
7 ##!not separating sections
9 echo -n "$S" |
sed -e 's/\$(/+/g' -e 's/)/-/g' | \
10 while read -r -N 1 A
; do
13 [ "$A" = "+" ] && PP
=$
(expr $PP + 1)
14 [ "$A" = "-" ] && MM
=$
(expr $MM + 1)
15 if [ "$PP" = "$MM" ]; then
16 if [ "$A" != "-" ]; then
24 ##!not separating sections
26 echo -n "$S" |
sed -e 's/\$(/+/g' -e 's/)/-/g' | \
27 while read -r -N 1 A
; do
30 [ "$PP" = "$MM" ] && oeq
=1 || oeq
=
31 [ "$A" = "+" ] && PP
=$
(expr $PP + 1)
32 [ "$A" = "-" ] && MM
=$
(expr $MM + 1)
33 [ "$PP" = "$MM" ] && eq
=1 || eq
=
34 [ -z "$oeq" -a -n "$eq" ] && echo -n "-"
35 if [ "$PP" != "$MM" ]; then
39 sed -e 's/+/$(/g' -e 's/-/)/g'
43 ##space separating sections
45 echo -n "$S" |
sed -e 's/\$(/+/g' -e 's/)/-/g' | \
46 while read -r -N 1 A
; do
49 [ "$PP" = "$MM" ] && oeq
=1 || oeq
=
50 [ "$A" = "+" ] && PP
=$
(expr $PP + 1)
51 [ "$A" = "-" ] && MM
=$
(expr $MM + 1)
52 [ "$PP" = "$MM" ] && eq
=1 || eq
=
53 [ -z "$oeq" -a -n "$eq" ] && echo -n "- "
54 if [ "$PP" != "$MM" ]; then
58 sed -e 's/+/$(/g' -e 's/-/)/g'
62 ##linefeed separating sections
64 (echo -n "$S"; echo -n ")") |
sed -e 's/\$(/+/g' -e 's/)/-/g' | \
65 while read -r -N 1 A
; do
68 [ "$PP" = "$MM" ] && oeq
=1 || oeq
=
69 [ "$A" = "+" ] && PP
=$
(expr $PP + 1)
70 [ "$A" = "-" ] && MM
=$
(expr $MM + 1)
71 [ "$PP" = "$MM" ] && eq
=1 || eq
=
72 [ \
( -z "$oeq" -a -n "$eq" \
) -a -n "$val" ] && echo && val
=
73 [ \
( "$MM" -gt "$PP" \
) -a -n "$val" ] && echo && val
=
74 if [ "$PP" = "$MM" ]; then
75 [ "$A" != "-" ] && echo -n "$A" && val
=1
80 ##linefeed separating sections
82 echo -n "$S" |
sed -e 's/\$(/+/g' -e 's/)/-/g' | \
83 while read -r -N 1 A
; do
86 [ "$PP" = "$MM" ] && oeq
=1 || oeq
=
87 [ "$A" = "+" ] && PP
=$
(expr $PP + 1)
88 [ "$A" = "-" ] && MM
=$
(expr $MM + 1)
89 [ "$PP" = "$MM" ] && eq
=1 || eq
=
90 [ -z "$oeq" -a -n "$eq" ] && echo -n "-" && echo
91 if [ "$PP" != "$MM" ]; then
95 sed -e 's/+/$(/g' -e 's/-/)/g'