Solaris tools sadness

Siddharth Agarwal sid at less-broken.com
Mon Nov 9 17:00:48 CST 2015


On 11/9/15 14:18, Danek Duvall wrote:
> I swear I'm working on some tooling to help me find these problems before
> release.
>
> In 3.6, the changeset 15ce78517d4b introduced some test cases for different
> bundle types.  I've run into two problems with the v2 bundles where it's
> not clear how to best work around them.
>
> One of them is due to a bug in Solaris head, where if a null character is
> encountered on a line, the rest of the line -- including the newline -- is
> ignored.  This ends up putting the next line into the output.  GNU head
> doesn't have this problem.  The bug on our end, while it was filed, was
> later closed because of a loophole in the standards text for head saying
> that the input needs to be text, and thus this isn't a standards-compliant
> use of head, so close-will-not-fix.  I don't agree with the analysis, but
> it's probably a heavy lift to get this one fixed.
>
> I can work around this by changing the command to be
>
>      cut -b 1-6 ../b$t | cat -v | head -n 1
>
> and changing the output to expect "^@^@" at the end.  Seems to work just
> fine with both our tools and with GNU.  Another alternative would be to use
>
>      cut -b 1-6 ../b$t | tr -d '\0' | head -n 1
>
> I could also just patch the test locally to use GNU head and be done with
> it, but I'd prefer not to have the patch maintenance, even for such a
> simple patch.
>
> Unfortunately, the second problem is worse, and I don't know of a sane way
> of working around it without patching the test.  In the "v2" bundle, there
> happen to be no newlines, so Solaris cut doesn't emit any, either (leading
> the next line of the output to be appended to the output of cut + head),
> while GNU cut ends up adding one.  It seems to me that the behavior of GNU
> cut is incorrect there (and thus I'd be reluctant to file a bug against
> Solaris cut), but that may now be unchangeable.
>
> What I've come up with to handle both bugs and that works with both Solaris
> and GNU utilities is (brace for it)
>
>      (cut -b 1-6 ../b$t | tr -d '\0' | head -n 1; echo) | tr -s '\n'
>
> Delete all the nulls, force an extra newline, then remove all duplicate
> newlines.
>
> If I sent this as a patch, would you laugh, or might it be accepted?  If
> it's just too funny, I can patch locally and go on my way.

What about tiny inline Python scripts that just verify the output?

- Siddharth

>
> Thanks,
> Danek
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list