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))"
8 ##linefeed separating sections
10 (echo -n "$S"; echo -n ")") |
sed -e 's/\$(/+/g' -e 's/)/-/g' | \
11 while read -r -N 1 A
; do
14 [ "$PP" = "$MM" ] && oeq
=1 || oeq
=
15 [ "$A" = "+" ] && PP
=$
(expr $PP + 1)
16 [ "$A" = "-" ] && MM
=$
(expr $MM + 1)
17 [ "$PP" = "$MM" ] && eq
=1 || eq
=
18 if [ -n "$oeq" -a -n "$eq" -a "$PP" = "$MM" ]; then
22 if [ -n "$oeq" -a -z "$eq" -a "$PP" != "$MM" ]; then
23 [ -n "$val" ] && echo && val
=
27 ##linefeed separating sections
29 echo -n "$S" |
sed -e 's/\$(/+/g' -e 's/)/-/g' | \
30 while read -r -N 1 A
; do
33 [ "$PP" = "$MM" ] && oeq
=1 || oeq
=
34 [ "$A" = "+" ] && PP
=$
(expr $PP + 1)
35 [ "$A" = "-" ] && MM
=$
(expr $MM + 1)
36 [ "$PP" = "$MM" ] && eq
=1 || eq
=
37 if [ \
( -z "$oeq" -a -n "$eq" -a "$PP" = "$MM" \
) -o \
( "$PP" != "$MM" \
) ]; then
39 [ "$PP" = "$MM" ] && echo
42 sed -e 's/+/$(/g' -e 's/-/)/g'