[Buildroot] [RFC] Slides "Using Buildroot for real projects"

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Mon Oct 24 16:42:06 UTC 2011


Thomas, All,

On Monday 24 October 2011 17:32:50 Thomas Petazzoni wrote:
> Le Sun, 23 Oct 2011 14:37:55 +0200,
> Baruch Siach <baruch at tkos.co.il> a écrit :
> 
> > 1. Slide 23: missing -e in the 'echo' command
> > 
> > $ echo "/dev/mtdblock7\t\t/applog\tjffs2\tdefaults\t\t0\t0"
> > /dev/mtdblock7\t\t/applog\tjffs2\tdefaults\t\t0\t0
> > 
> > $ echo -e "/dev/mtdblock7\t\t/applog\tjffs2\tdefaults\t\t0\t0"
> > /dev/mtdblock7      /applog jffs2   defaults        0   0
> 
> -e is not needed with sh:

The problem is that /bin/sh might be whatever. With a POSIX-conformant
/bin/sh (eg. dash), this is true. With bash, it is not. Alas, many
systems still have bash as /bin/sh.

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 May 17 23:53 /bin/sh -> bash
$ echo "bli\nbla"
bli\nbla
$ /bin/bash
$ echo "bli\nbla"
bli\nbla
$ exit
$ /bin/dash
$ echo "bli\nbla"
bli
bla

The answer it to use printf [0].

I now use printf as much as I can. printf is in POSIX and does not suffer
from all the discrepancies there are in the many echo implementations.

> $ echo "bla\nbli"
> bla
> bli
> $ echo -e "bla\nbli"
> -e bla
> bli

[0] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'



More information about the buildroot mailing list