The txtar file format is simple, but too simple. For example, an archive containing the file go/src/cmd/go/internal/txtar/archive_test.go itself will not round-trip correctly, because that file contains literals that look like file separators.
The spec should include an escaping/quoting scheme.
Personally, I like the ultra-simple nature of the file format, although it's true that sometimes you do want to have a file that contains the separators. That's possible to work around, however. In this fork of testscript, I've provided unquote as a standard primitive. It just removes the leading > from the start of each line. I also changed the txtar-c command so that you can ask it to do the quoting for you.
Perhaps that approach might work for the internal testscript code too.
@jayconrod @bcmills
Agree with @rogpeppe, the simplicity of this format is really valuable. I'd rather not add features to it.
@ianthehat mentioned another case that doesn't roundtrip correctly: files that don't end with a newline. As with the unquote feature above, he recommends processing these files before and after packing them into txtar (adding newlines to files before packing, removing newlines after).
Most helpful comment
Personally, I like the ultra-simple nature of the file format, although it's true that sometimes you do want to have a file that contains the separators. That's possible to work around, however. In this fork of testscript, I've provided
unquoteas a standard primitive. It just removes the leading>from the start of each line. I also changed thetxtar-ccommand so that you can ask it to do the quoting for you.Perhaps that approach might work for the internal testscript code too.