Bash syntax highlighting of subshells

bashsubshellsyntax highlighting

Considering the large amount of questions which turn out to be related to subshells in Bash ("Why doesn't my variable increment in this piped while read loop?"), I just thought it would be very nice to refer to some editor or service where code which will be executed in subshells is formatted differently from the code executed in the parent shell. It might be useful as an educational device (see the difference between code | code and code < <(code) instantly). Does this exist?

Bonus points if anyone implements it for jEdit or VIm.

Obviously it doesn't have to be perfect (no syntax highlighting is, in my experience), but I suspect things like (foo=bar; echo $foo;) and command | while read ... shouldn't be too difficult for a start.

Best Answer

I don't think this exists. It would be useful, but hard to implement by standard means of syntax parsing used in editors. From the parsing point of view, there are many keywords and special symbols that would have to be analysed to determine a block of code that belongs to a subshell.

But I'd be happy to see I'm wrong and someone has put the effort needed to create such configurations.

Related Question