#245 Bash, #, and ^G


In Bash, the '#' character means that the rest of the line is a comment, except when it means something else...

I went through the Bash manual looking for different uses of '#'. The attached file has a function for every different use I found. Try hitting ^G on each of the curly brackets. Delimiter matching works fine in functions "f" and "l". I expected "l" to work, but I was a bit surprised about "f". For all the others, the first '}' is ignored because of the preceding '#'.

Functions "k" and "m" are also not handled properly by the syntax highlighter.

"!#" doesn't do much in a script. It is meant for an interactive shell, but it is accepted in a script without being reported as a syntax error. Without the '!', it is reported as a syntax error.

A use of '#' like that in function "h" is what bit me in the wild.


Patches: #106


  • Joe Allen

    Joe Allen - 2008-11-04

    Ugh.. I need a user definable state machine for ^G.

  • Charles J. Tabony

    If only we could leverage the existing state machine... :-)

    See patch 3459260.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks