split -e currently discards input prior to the first appearance of the given expression. This seems to be undesirable behavior, as split should preserve all input data (unless -x is given, which is unconnected to this issue). The cause is the output Biobuf lacking an initial file association prior to the first time the regexp test is passed. This patch moves the match array declaration and initial call to matchfile to prior to entering the output loop. Tested by mycroftiv and the initial bugfinder. No manpage change necessary, I believe preserving all input data is the intended behavior of split. Reference: /n/sources/patch/applied/split-fixe Date: Mon Jul 27 02:23:13 CES 2009 Signed-off-by: mycroftiv@sphericalharmony.com --- /sys/src/cmd/split.c Sun Jul 26 01:42:03 2009 +++ /sys/src/cmd/split.c Sun Jul 26 01:42:02 2009 @@ -70,10 +70,12 @@ Binit(b, 0, OREAD); if(pattern) { + Resub match[2]; if(!(exp = regcomp(iflag? fold(pattern,strlen(pattern)): pattern))) badexp(); + memset(match, 0, sizeof match); + matchfile(match); while((line=Brdline(b,'\n')) != 0) { - Resub match[2]; memset(match, 0, sizeof match); line[Blinelen(b)-1] = 0; if(regexec(exp,iflag?fold(line,Blinelen(b)-1):line,match,2)) {