[OE-core] [PATCH] Replace "echo -e" with "printf" to have the same behavior in dash or bash

Andrei Gherzan andrei at gherzan.ro
Thu Sep 20 09:17:11 UTC 2012


On Thu, Sep 20, 2012 at 12:13 PM, Paul Eggleton <
paul.eggleton at linux.intel.com> wrote:

> On Thursday 20 September 2012 11:44:39 Andrei Gherzan wrote:
> > oe-core removed the prerequisite to have sh as bash. POSIX doesn't define
> > any options and furthermore allows echo -e to be the default behavior.
> > This means that in dash "echo -e" will actually print "-e" and interpret
> > backslashes by default. We use instead "printf" builtin command with or
> > without "\n" to simulate echo -e or echo -n.
>
> I haven't looked over the whole patch, but I did notice a couple of issues
> -
> printf does not behave exactly like echo in a couple of situations:
>
>  (a) if you supply no arguments printf will return an error whereas echo
> does
> not, this will probably break situations where you have changed the script
> to
> do 'printf > /some/file'. Since these statements are usually intended to
> create
> or truncate the specified file, I wonder if we should just change these to
> do '>
> /some/file' instead which works for dash and bash (and doesn't otherwise
> appear
> to be a bashism).
>
>
Already fixed. Patch was on the way.


>  (b) 'printf "\n"' will print just one newline, whereas echo -e "\n" prints
> two. Not sure if this is significant but I think we would rather keep the
> behaviour the same.
>
>
I didn't notice this but you are right. Just tested... I will add this as
well. Thank you.

ag
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20120920/ad1336a8/attachment-0002.html>


More information about the Openembedded-core mailing list