[ My apologies if this is the wrong place to report this, I'm not familiar with the TCL dev infrastructure. ]
In our project I wrote a TCL line:
...
verbose -log "$fmt [get_line_1 $y "" $attrs]"
...
and there was some discussion on whether this is valid TCL syntax, so it got changed ( https://sourceware.org/pipermail/gdb-patches/2025-July/219538.html ) to:
...
verbose -log "$fmt [get_line_1 $y {} $attrs]"
...
The TCL interpreter seems to handle the two lines the same, so I'm assuming it's valid syntax.
Regardless, it's not clear from the syntax definition whether it's valid or not.
The syntax definition states:
...
If the first character of a word is double-quote (“"”) then the word is terminated by the next double-quote character.
...
So the question is, what is the "next double-quote character" in this case. This:
...
verbose -log "$fmt [get_line_1 $y "" $attrs]"
^
...
or this:
...
verbose -log "$fmt [get_line_1 $y "" $attrs]"
^
...
?
If it is the latter, then the use of the term "next double-quote character" is misleading.
I think the same problem exists more or less for:
...
"foo \" bar"
...
but in this case the definition of backslash substitution explains that \" is treated as an ordinary character, which explains why \" doesn't terminate the string.
But in the case of the command substitution definition, there's no such explanation, though one could argue that it can be inferred from "invokes the Tcl interpreter recursively to process the characters following the open bracket as a Tcl script".
My guess at an improved formulation would be something like:
...
Double quotes.
If the first character of a word is double-quote (“"”) then the word is terminated by the next double-quote character (that is not substituted by backslash or command substitution). If semi-colons, close brackets, or white space characters (including newlines) appear between the quotes then they are treated as ordinary characters and included in the word. Command substitution, variable substitution, and backslash substitution are performed on the characters between the quotes as described below. The double-quotes are not retained as part of the word.
...
|