Bugs and assumptions

There's a fine line between an assumption and a bug. If the assumptions are spelled out ahead of time, then it's not a bug if the script does what's expected, taking the assumptions into consideration.

Having disclaimed that, then, here are some of the assumptions made for the makefiles.cmd and delallbut.cmd scripts:

makefiles.cmd

1. This script assumes that the files that you'd like to create are either all in the same directory or that if you specify paths as arguments, that all directories you refer to already exist. It will not create directories on the fly.

For example, if you were to run makefiles.cmd foo bar baz you would end up with three files in the current directory: foo, bar, and baz. If, however, you were to run makefiles.cmd dir1\foo dir2\bar dir3\subdir3\baz, you'd better make sure that dir1, dir2, and dir3\subdir3 already exist or you'll get "The system cannot find the path specified" for each path that it can't get to.

2. For files you specify on the command line, if there are already files of that name, they'll get clobbered. This could easily be remedied by using >> rather than >. The single > will spew the result of a command into a file specified. The double >> will append to an existing file. This is important to remember when you're writing scripts that create logfiles, for example. I've been bitten by this before...

 

delallbut.cmd

Anders is absolutely correct on both points:

1. If you have a file that already has the read-only flag set, this script will not delete it.

Example: Create files foo, bar, baz, and gingerbreadman (makefiles.cmd is great for testing this, by the way). Now make, say, gingerbreadman read-only (attrib +r gingerbreadman). When you run delallbut.cmd foo, you'll see that gingerbreadman still exists in that directory (can't del me, I'm the Gingerbread Man!).

2. If the file you choose not to delete already had the read-only flag set, this script will strip it off once it's done running. If you depend on behavior #1 up there, you'll be unpleasantly surprised when you run this and find that your previously saved file suddenly disappears.

Example: Create files foo, bar, baz, and gingerbreadman again. Set the +r flag on gingerbreadman. Run delallbut.cmd gingerbreadman. Now gingerbreadman still exists, but it no longer has the +r flag set. Create file saveme. Run delallbut.cmd saveme. Uh-oh! Gingerbreadman is gone! Gumdrop buttons and all!

 

So, are these bugs? Not anymore - I've spelled out the assumptions...