Artifacts Associated With Ticket 1047097
Ticket change [cb4ff04967] (rid 95492) by nobody on 2004-10-14 15:06:02:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Synopsis of the bug: Possible issue with the way tcl parses list commands. 1. If the list being passed to one of the list commands is followed by any nonspace "terminator" character (such as "[", ",", ".", "{", "}", ")", "\" and etc. ) and then by any number of nonspace characters then space , all those characters are being appended to the very last element of the list while executing the command. Example: ---------- input: join [list 1 2 3]\[ | output: 1|2|3[ input: join [list 1 2 3]] | output: 1|2|3] 2. If the list being passed to one of the list commands is followed by any nonspace "terminator" character (such as "[", ",", ".", "{", "}", ")", "\" and etc. ) and then by any number of nonspace characters, then by "\", then by a space character, and then again any number of nonspace characters, all those characters before "\ " are being appended to the very last element of the passed list and all characters that goes after "\ " are treated as an additional last element of the list while executing the command. Example: ---------- input: join $l\extra1\ extra2 | output: 1|2|3extra1|extra2 Setup information: OS: Windows 2000 Professional, TCL: Tcl version 8.3 Steps to reproduce the bug: 1. Bring up tclsh command prompt 2. Initialize the list as below... input: set l [list 1 2 3] output: 1 2 3 3. Try one of the operation below (join is used only as an example any other list operation will manifest the same issue) input: join $l] | output: 1|2|3] input: join $l{ | output: 1|2|3{ input: join $l} | output: 1|2|3} input: join $l) | output: 1|2|3) input: join $l. | output: 1|2|3. input: join $l, | output: 1|2|3, input: join $l\asdf | output: 1|2|3sdf input: join $l\( | output: 1|2|3( input: join $l\[ | output: 1|2|3[ input: join $l\] | output: 1|2|3] input: join $l\\ | output: 1|2|3\ input: join [list 1 2 3]\[ | output: 1|2|3[ input: join $l\extra1\ extra2 | output: 1|2|3extra1|extra2 Expected result: Parsing error. - foundin initialized to: "final ----"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "17. Commands I-L"
- title initialized to:
Possible parsing problem. "list" command inccorectly assigns
- type initialized to: "Bug"
Ticket change [01c4a14eb7] (rid 119541) by nobody on 2004-10-18 18:13:48:
- icomment:
Logged In: NO I am not sure about cases containing chars like [ and { but at least this: input: join $l, | output: 1|2|3, is IMHO perfectly OK - list $l is converted to string, then comma is appended to it while forming the first arg to 'join', then it is converted back to list because 'join' wants a list. In fact it has nothing to do with lists at all, the only question might be whether all those combinations of special characters in arguments are written in the best possible quoting style and whether parser could enforce a better style, for example: input: join $l} | output: 1|2|3} is rather unfortunate when used as part of bigger script, I would rather backslash-escape the brace: input: join $l\} | output: 1|2|3} Vaclav Hanzl - login: "nobody"
- mimetype: "text/plain"
- username: "nobody"
- icomment:
Ticket change [45bbc638d7] (rid 99399) by dkf on 2004-10-19 20:45:08:
- closedate changed to: "2004-10-19T13:45:08"
- closer changed to: "dkf"
- foundin changed to: "final: 8.3.5"
- icomment:
Logged In: YES user_id=79902 These are all not bugs; just funny (and inefficient) ways to construct lists. Tcl, by definition, concatenates lists and characters by converting the list to a string and concatenating strings. Then the join command (or any other list-consuming command) reinterprets the resulting string as a list again. Of the characters you list ("[", ",", ".", "{", "}", ")", "\"), all except the {curly braces} and backslash have no meaning to the list parsing engine at all. When a curly brace starts a word in a list, that word extends up to the matching closing curly (which must not have any trailing chars) but that is the only time they are significant. Backslashes are special in front of some characters, but you have to distinguish between quoting them to the command you're typing in and the actual list engine. To summarize, what you've written is all correct and intended (if perhaps surprising the first time you encounter it.) - login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- subsystem changed to: "14. List Object"
- username: "dkf"