Saturday, December 10, 2011

Re: bash highlighting problem...



Taylor Hedberg wrote:
Linda W, Fri 2011-12-09 @ 02:46:15-0800:   
As for the red flagging...  I thought it was for syntax errors?   since it isn't a syntax error, but merely an older standard, shouldn't it not be flagged as illegal?     
 Yeah, it should probably be accepted as valid syntax by Vim despite its deprecation, since it does still work in the current bash 4.2. It's likely that the creator of the sh.vim syntax file just didn't know about that older syntax.  The same goes for the for loop with braces, though I can't find any reference at all to that syntax online. Is that an older form as well?  In any case, regardless of how Vim handles syntax highlighting in bash scripts, it's probably better in general to stick with the more widely accepted syntax for this sort of thing. If nothing else, it avoids confusing people who don't know about the undocumented versions when they read your code. :)   
----
       Um, I learned about it by reading other people's code....if such things easily confuse
people, maybe they shouldn't be programming?

    As for the braces, -- they 'group'... but they don't nest...

so you can't use nested braces (like
for(){
if (){
}
}
but you can use 1 or the other in a single for/if... but bash can't
handle parsing nested {}, as they are also used on vars.  It can be done,
(perl mostly does it), but even perl can get confused......and do the wrong
thing.  Rather than requiring keywords to make things more deterministic,
perl requires a bit more consideration in usage...(it's errors can be far
more cryptic)... bash's errors, in comparison, are usually more straightforward.


No comments: