On Fri, Jan 25, 2019 at 12:52 PM Elijah Newren <new...@gmail.com> wrote:
> On Fri, Jan 25, 2019 at 9:41 AM Derrick Stolee <sto...@gmail.com> wrote:
> > On 1/25/2019 11:54 AM, Elijah Newren wrote:
> > > +     printf "0f9645804ebb04cc3eef91f799eb7fb54d70cefb\0::100644 100644 
> > > 100644 f00c965d8307308469e537302baa73048488f162 
> > > 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 
> > > 333b9c62519f285e1854830ade0fe1ef1d40ee1b 
> > > RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect &&
> >
> > I'm guessing that you use printf here because the
> > 'cat <<-\EOF' approach doesn't work with the special
> > tabs? Kudos for putting in the extra effort here for
> > the special formatting!
>
> Yeah, I didn't know how to easily get NUL bytes in the stream without
> printf, and once I was using printf the EOF HEREDOC no longer had a
> useful purpose.  In the first testcase, since there were only
> printable characters in the expected output, a HEREDOC worked well.  I
> guess I could have just used printf for both testcases, but having the
> literal output shown where it's possible for a human to read it seemed
> like an advantage worth capitalizing on.

If the readability of a here-doc is preferred, you should be able to
achieve the desired result with the q_to_tab() and lf_to_nul()
functions. For instance:

    q_to_tab <<-\EOF | lf_to_nul >expect &&
    ...Q...Q...
    EOF

Reply via email to