views:

44

answers:

1

I haven't used tcl before and just need to do one trick, I can do it trivially in something like bash but I need it to work cross-platform (e.g. tcl in cygwin on windows).

Can someone suggest a short (5-10) obfuscated function that just returns 0 after taking two string args? It just can't do something like run shell commands that won't work under Mac/Cygwin.

fwiw, why do this: buying some time in writing a test- the thing generating one of the files is broken but I can't change it, making a hack in the TCL test script until I make extensive changes to use a different 'test core' that isn't broken. For now just declare the first file as 'good' if it exists.

+2  A: 

I don't understand the requirement for obfuscation, but the simplest way to create a command that takes two arguments and returns 0 is this:

proc theCommandName {firstArgument secondArgument} {
    return 0
}

There are all sorts of ways of making things obscure (e.g., a regular expression that doesn't actually match anything, a complicated expression) but as I said before, I don't understand the requirement in that area; I always try to make my code be the simplest thing that could possibly work…

Donal Fellows
BTW, the above code snippet and ideas are totally cross-platform because they don't do anything at all with the OS. Every Tcl interpreter will be able to handle them.
Donal Fellows
"a regular expression that doesn't actually match anything" good idea... was just worried about cross-platform.Its a 'political/bureaucratic' thing unfortunately. I'm getting complaints about an auto-tester failing on certain platforms because binary files aren't identical, but its not my code's fault, its the way the writer does round-off before printing to XML. So I wanted to just make the test always pass to buy some time, then find a different way to compare files. Its a bunch of work because the feature I'm adding doesn't have an industry-standard file writer, etc etc...
peter karasev
@peter: You have my sympathy. If you're using `tcltest` to manage the testing, you can add custom matching modes so that you can better control what “equal” means (e.g., floats that are equal within epsilon).
Donal Fellows