commit 749e305d3671368a8d08de002f5235298ed1ed53

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Thu Nov 25 08:29:01 UTC 2010


On Thu, 25 Nov 2010, Denys Vlasenko wrote:
> On Wednesday 24 November 2010 22:30, Cristian Ionescu-Idbohrn wrote:
> > +               # need to use printf: different shells have inconsistent
> > +               # rules re handling of "\n" in their params,
> > +               # and ${insert} definitely contains "\n"
> > +               printf "%s\n" "${header}"
> >
> > Not sure that would work the way you expect it to.
>
> How do you think I expect it to work?
>
> > Consider this example:
> >
> > ,----
> > | #!/bin/dash
> > |
> > | set -e
> > | set -u
> > | #set -x
> > |
> > | insert="foo\n"
> > |
> > | printf "1. insert='%s'\n" "$insert"
> > | printf "2. insert='$insert'\n"
> > `----
> >
> > The output of that on my box is:
> >
> > 	1. insert='foo\n'
> > 	2. insert='foo
> > '
> >
> > That is, the expected newline after fooin (1), isn't.
>
> Sorry, what it has to do with *my* code? I use printf "%s\n" ...
> not printf "blah blah '%s'\n" ...

Sorry about that.  Please ignore what I wrote.  You're right.
Your code and mine are different.


Cheers,

-- 
Cristian


More information about the busybox mailing list