#245 Bash, #, and ^G

v4.1
closed-fixed
None
v4.5
5
2017-09-26
2008-11-04
No

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.

Related

Patches: #106

Discussion

  • 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.

     
  • John J. Jordan

    John J. Jordan - 2017-09-26
    • status: open --> closed-fixed
    • assigned_to: John J. Jordan
    • Applies To: --> v4.5
    • Group: --> v4.1
     
  • John J. Jordan

    John J. Jordan - 2017-09-26

    This went in 4.1

     

Log in to post a comment.