bashpp icon indicating copy to clipboard operation
bashpp copied to clipboard

Normal comments

Open CMCDragonkai opened this issue 8 years ago • 4 comments

Why are normal comments failing?

#this is a comment

But this works:

# this is a comment

Shouldn't we only parse things that are actual directives?

CMCDragonkai avatar Aug 11 '16 13:08 CMCDragonkai

Yeah. What's the error you're seeing? I can set up a test for this and check, but it seems low priority.

iwonbigbro avatar Aug 22 '16 22:08 iwonbigbro

Ok, so it treats anything that is prefixed with # as a directive. If a directive is not defined, then it errors:

t/test_comments.sh
/var/folders/mr/bvl8x82d1490cbs708m_pt5hl1gfd3/T/tmp.ioAw3QDm:1:19 error: 1: invalid directive: this
  #this is a comment
  ..................^

We'd be in danger of allowing typos through the net, like:

#defnie SOMETHING

Since defnie is not defined, it would generate a script with undefined behaviour. By explicitly requiring comments include the additional space, we save ourselves this potential pain.

iwonbigbro avatar Aug 22 '16 22:08 iwonbigbro

However this can break a lot of scripts. Isn't it possible to only process correctly structured macros. So that if the original script had a typo, then that script should be fixed. Also I'd imagine that #defnie SOMETHING should just not be evaluated, and left as a comment.

CMCDragonkai avatar Aug 24 '16 04:08 CMCDragonkai

Well let's compromise. I'll add an option that will treat an undefined directive as a comment, but the default behaviour will be to warn. I'll add a message to the warning to try the option.

iwonbigbro avatar Aug 24 '16 07:08 iwonbigbro