On Mon, Jan 4, 2016 at 11:15 PM, Michal Mazurek <akf...@jasminek.net> wrote: > On 01:24:35, 5.01.16, Ingo Schwarze wrote: >> +If an output line would be broken after a non-blank character but >> +contains at least one blank character, break the line earlier, >> +after the last blank character. >> +This is useful to avoid line breaks in the middle of words, if >> +possible. > > After a second look, even though the current documentation mentions > a "blank character" the source code shows that in fact a space is meant: > > if (split_words) { > for (i = 0, last_space = -1; i < indx; i++) > if(buf[i] == ' ') > last_space = i; > }
For a utility like fold(1) which is covered by the POSIX/Single Unix Specification, we should think hard about diverging from the the spec. SUSv7 says: -s If a segment of a line contains a <blank> within the first width column positions (or bytes), break the line after the last such <blank> meeting the width constraints. If there is no <blank> meeting the requirements, the -s option shall have no effect for that output segment of the input line. which seems to agree with the current manpage, suggesting the code--not the documentation--is wrong. (Yes, OpenBSD diverges from POSIX on some points...where we explicitly think POSIX is unsafe or Wrong. To my knowledge, this is not one of those.) Philip Guenther