Except chokes on files with right parens

Jul 7, 2008
18
1
#1
If you try to specifically 'exclude' a file that has a right parenthesis in its filename, it appears that the exclude code treats the parenthesis as the closing paren for the exclusion list. For example:

> except (test(1.2).txt) dir *
TCC: Unknown command ".txt)"

Even putting the filename in quotes fails, with a slightly different output:

> except("test(1.2).txt") dir *
TCC: Unknown command ".txt) dir *"

(edit: this is on "TCC 15.01.51 x64 Windows 7 [Version 6.1.7601]")
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,641
46
Albuquerque, NM
prospero.unm.edu
#2
That is odd. Escaping the close pat doesn't seem to help, either. Perhaps you can use a question mark as a temporary workaround...?

For internal commands, I recommend that you use an exclusion range instead of EXCEPT. EXCEPT is really only there for the benefit of external commands. (Maybe you just picked DIR for purposes of illustrating the issue, in which case please disregard this comment.)
 

rconn

Administrator
Staff member
May 14, 2008
10,606
97
#3
If you try to specifically 'exclude' a file that has a right parenthesis in its filename, it appears that the exclude code treats the parenthesis as the closing paren for the exclusion list. For example:

> except (test(1.2).txt) dir *
TCC: Unknown command ".txt)"

Even putting the filename in quotes fails, with a slightly different output:

> except("test(1.2).txt") dir *
TCC: Unknown command ".txt) dir *"
The first example is invalid syntax is wrong; the embedded '(' doesn't mean anything to the parser, so it terminates on the first ')' it finds.

The second example should have worked -- except that EXCEPT is (99.9%) obsolete, and hadn't been updated since DOS (where double quotes didn't mean anything either). I have made a change for the next build (15.01.52) which will ignore embedded )'s within double quotes.
 
Jul 7, 2008
18
1
#4
The first example is invalid syntax is wrong; the embedded '(' doesn't mean anything to the parser, so it terminates on the first ')' it finds.

The second example should have worked -- except that EXCEPT is (99.9%) obsolete, and hadn't been updated since DOS (where double quotes didn't mean anything either). I have made a change for the next build (15.01.52) which will ignore embedded )'s within double quotes.
I'm not quite sure why the first example syntax is wrong; doing a 'dir test(1,2).txt' from a win 7 cmd.exe prompt works fine, so I would expect the same behavior within the exclude block. In any case, I appreciate the fix. I have files with version numbers in parens that are useful for compares/diffs/unit tests and want to exclude them from certain external commands.

[EDIT] I haven't used exclusion ranges much, but they probably are the right solution in most cases for me.

One suggestion: it would be very helpful if the /[=] popup dialog had checkboxes to create exclusions for size/date/owner/etc ranges (ie, prepend the ! operator to these options) and to allow the 'results" textbox at the bottom of the dialog to be fully editable so that a complex range combination can be created and then copied for subsequent use. I would personally prefer that the results then replace the command-line command in situ so that the fully formulated command enters the history list rather than the /[=] command. Perhaps something to think about?

Again, thanks. -- Casey
 

rconn

Administrator
Staff member
May 14, 2008
10,606
97
#5
I'm not quite sure why the first example syntax is wrong; doing a 'dir test(1,2).txt' from a win 7 cmd.exe prompt works fine, so I would expect the same behavior within the exclude block. In any case, I appreciate the fix. I have files with version numbers in parens that are useful for compares/diffs/unit tests and want to exclude them from certain external commands.

A "dir test(1,2).txt" will work fine in TCC too. But it won't work in EXCEPT.

The problem is that there is no reason for the TCC parser to think that a leading '(' has to have a matching trailing ')'. (And yes, I've seen lots of filenames with mismatched parens.) So when you insert the filename into the parenthesized EXCEPT argument, the parser can only assume it should end at the first ')' it finds.