Skip to content
zit Two names that could not be spelled
Login

Two names that could not be spelled

Both fixes in 0.3.25 are about a name the tool stored correctly and could not hand back.

A file called -x.txt was unreachable by any spelling. Passed bare it parses as an option, which is ordinary and expected; what was missing was the escape every other command-line tool has. -- was itself rejected as an unknown option. The usual fallback does not apply here either, because a path is compared literally against the check-in's file list, so ./-x.txt parses cleanly and then resolves to nothing. Two spellings, neither reaching the file. A forge serving such a repository answered 500 on every content route for it, because the zit cat underneath could not be written.

The surprise on opening the parser was that twenty of the forty-five argument parsers already honoured the marker, including the shared flag scanner behind add, rm, commit and mv. The convention had been implemented wherever a parser happened to be written against the shared scanner or as a small state machine, and skipped wherever the parser was a hand-rolled loop. Twenty-five of those, cat among them.

The fix gates each option branch behind the marker rather than teaching each parser a second copy of its own operand handling. Once the option branches stop matching, the token falls through to the positional branches that were already there, so -n after -- becomes a name rather than a limit flag and no parser grew a duplicate tail. Three tests pinned the old behaviour and now pin the new one, which is what that kind of change should look like.

The documentation went somewhere the first attempt did not. Adding the marker to the shared help blob put it in the options table of thirty-nine verbs, and two rules objected at once: a test requiring every options-table flag to appear in its verb's usage line, and end-to-end tests pinning several verbs' help verbatim. Both were saying the same thing. -- is not a verb's option, it is the rule every verb parses by, so it became its own topic, zit help options.

The second fix is smaller and the same shape. zit zip wrote member names as UTF-8 and never set the general-purpose bit that says so, and a conforming reader must then read them as CP437: a committed café.txt extracted as caf├⌐.txt. The bytes were right the whole time; only the label was missing. Both the local header and the central directory now take the flag from one constant, because a reader trusts the central record for metadata and fixing the local one alone would have changed nothing a user sees.