this was an interesting diversion
a text file with size>0 and newline!=last-char has an incomplete line
the head and tail descriptions do not mention incomplete lines
but head has some text that is equivalent to "incomplete line counts as a line":
When a file contains less than number lines, it shall be copied
to standard output in its entirety. This shall not be an error.
for consistency tail should treat incomplete lines the same way head does
given that, both the current ast head and ast tail are inconsistent w.r.t.
incomplete lines
head was easy to fix by implementing the "entirety" text above
tail was a bit more interesting because it if revealed a bug in
sfmove(from,to,size,record_sep)
when record_sep is '\n' -- it loses the data for an incomplete line
fixing tail involved checking if sfmove() hit an incomplete line and
then calling sfmove(...,-1) to move all remaining *and* fixing sfmove(...,-1)
to recognize that an incomplete line was hit
regression tests were added to src/cmd/builtin and now head and tail align with
gnu
from what I can tell the standard conformance tests completely miss this issue
this will be in the next alpha
and that will be early next week
On Thu, 19 Sep 2013 22:36:44 +0200 Roland Mainz wrote:
> On Thu, Sep 19, 2013 at 8:53 PM, FELLIN, JEFFREY K (JEFF)
> wrote:
> > When I test printf "foo" >bar there is no newline in the file:
> > $ printf "foo" >bar
> > $ od -bc bar
> > 000 146 157 157
> > f o o
> > 003
> >
> > So if head -1 is suppose to print the first line, there is no end of line,
> > hence to no line. Given the definition of head prints lines, wouldn't a
> > file containing no newline chars, not have any output from head?
> One counterargument may be that we're talking about the "last line",
> which may/should be always printed, regardless whether it has a
> newline or not.
> The other issue is that I can't find a head(1) implementation which
> behaves like AST head(1) with Irek's example:
> On Solaris 10 (/usr/bin/head is the natiev SystemV implementation, not
> the head(1) from AST) I get this:
> -- snip --
> $ bash -c 'printf "foo" >bar ; /usr/bin/head -1 bar ; printf '\n''
> foo
> $ bash -c 'printf "foo" >bar ; /usr/gnu/bin/head -1 bar ; printf '\n''
> foo
> $ bash -c 'printf "foo" >bar ; /usr/bsd/bin/head -1 bar ; printf '\n''
> foo
> -- snip --
> On SuSE/Linux I get this for GNU coreutils and busybox head(1):
> -- snip --
> $ bash -c 'printf "foo" >bar ; /usr/bin/head -1 bar ; printf '\n''
> foo
> $ printf "foo" >bar ; busybox head -1 bar ; printf '\n'
> foo
> -- snip --
> Erm... this looks pretty much uniform... ;-/
>
> Bye,
> Roland
> --
> __ . . __
> (o.\ \/ /.o) roland.ma...@nrubsig.org
> \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
> /O /==\ O\ TEL +49 641 3992797
> (;O/ \/ \O;)
___
ast-users mailing list
ast-users@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-users