[Toybox] Posix is terrible: cut(1) edition.

Rob Landley rob at landley.net
Thu Jun 14 12:44:18 PDT 2018


Commit 2d893a4077c1 made cut match posix, which means it broke using 'cut -DF'
as an awk replacement because:

  echo hello | awk '{print $2}'
  echo hello | toybox cut -DF 2

First prints a blank line, second prints hello. There's a -s but then it doesn't
print the blank line so the behavior is still different.

Any suggestions on which way I should violate posix here? Obvious options:

1) -F disables the "no delimiter means show whole line" lunacy, since that's a
new option anyway. But then that's a magic side effect, which I'm uncomfortable
with.

2) make -s print a blank line, because "echo -e 'one\ntwo\nthree' | cut -b 8-10"
already _does_ and the current behavior is inconsistent. Whether this is a
violation of posix depends on what you think "suppress" means, although the
gnu/dammit version interpreted it to mean not printing anything.

3) Make -s print a blank line with -F. Still magic side effect.

4) revert the october commit, add a "deviations from posix" note, and wait for
somebody to complain. I don't _think_ anybody asked for it, I think I just
noticed it reading the posix spec to fill out cut.tests...

Opinions? I'm leaning towards #4 at the moment...

Hang on, I also added -D. And that disables a stupid posix thing cut is doing, I
should probably just make it disable this other stupid posix thing cut is doing
too...

Rob



More information about the Toybox mailing list