Re: [PATCH] test doc: test_write_lines does not split its arguments
On Mon, May 05, 2014 at 04:51:43PM -0700, Jonathan Nieder wrote:
Show 7 quoted lines
> test_write_lines carefully quotes its arguments as "$@", so
>
> test_write_lines "a b" c
>
> writes two lines as requested, not three.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Show 57 quoted lines
> ---
> Hi,
>
> Michael S. Tsirkin wrote:
>
> > +++ b/t/README
> > @@ -596,6 +596,28 @@ library for your script to use.
> > + test_write_lines "a b c d e f g" >foo
> > +
> > + Is a more compact equivalent of:
> > + cat >foo <<-EOF
> > + a
> > + b
> [...]
> > +++ b/t/test-lib-functions.sh
> > @@ -717,6 +717,11 @@ test_ln_s_add () {
> > fi
> > }
> >
> > +# This function writes out its parameters, one per line
> > +test_write_lines () {
> > + printf "%s\n" "$@"
> > +}
>
> How about this patch?
>
> Thanks,
> Jonathan
>
> t/README | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/t/README b/t/README
> index 2d6232f..8a9d499 100644
> --- a/t/README
> +++ b/t/README
> @@ -596,15 +596,14 @@ library for your script to use.
> ...
> '
>
> - - test_write_lines <text>
> + - test_write_lines <lines>
>
> - Split <text> to white-space separated words and write it out on standard
> - output, one word per line.
> + Write <lines> on standard output, one line per argument.
> Useful to prepare multi-line files in a compact form.
>
> Example:
>
> - test_write_lines "a b c d e f g" >foo
> + test_write_lines a b c d e f g >foo
>
> Is a more compact equivalent of:
> cat >foo <<-EOF
> --
> 1.9.1.423.g4596e3a