I agree Paul, I wasn't sure that dash was/wasn't compliant. It is the default with the latest Ubuntu for /bin/sh, which means busybox builds don't work on Ubuntu by default. <br><br>Since the question was raised about posix compliance, I decided to go look it up. Here is what I found:
<br><br>Here are the posix specs:<br>(free registration required)<br><br>Here is the main link:<br><a href="http://www.unix.org/single_unix_specification/">http://www.unix.org/single_unix_specification/</a><br><br>here are some direct links:
<br><a href="http://www.opengroup.org/onlinepubs/000095399/utilities/xcu_chap02.html#tag_02_02">http://www.opengroup.org/onlinepubs/000095399/utilities/xcu_chap02.html#tag_02_02</a><br><a href="http://www.opengroup.org/onlinepubs/000095399/utilities/xcu_chap02.html#tag_02_06_03">
http://www.opengroup.org/onlinepubs/000095399/utilities/xcu_chap02.html#tag_02_06_03</a><br><a href="http://www.opengroup.org/onlinepubs/000095399/utilities/echo.html">http://www.opengroup.org/onlinepubs/000095399/utilities/echo.html
</a><br>
<br>Here are some excerpts for consideration:<br><br>2.6.3 Command Substitution<br>"Within the backquoted style of command substitution, backslash shall retain its literal meaning, except when followed by:
<tt>'$'</tt>, <tt>'`'</tt>, or <tt>'\'</tt> (dollar sign, backquote, backslash). <br>...<br>A single-quoted or double-quoted string that begins, but does not end, within the <tt>"`...`"</tt>
sequence produces undefined results."<br><br>so a single " or ' is undefined behavior within a backquote command substitution and cannot be escaped with a backslash.<br><br>echo:<br>"It is not possible to use
<i>echo</i> portably across all POSIX systems unless both <b>-n</b> (as the first argument) and escape
sequences are omitted."<br><br><p>"The following operands shall be supported:</p>
<dl compact="compact"><dt><i>string</i></dt><dd>A string to be written to standard output. If the first operand is <b>-n</b>, or if any of the operands contain a backslash (
<tt>'\'</tt> ) character, the results are implementation-defined.</dd><dt>...<br></dt><dt><tt> \n</tt></dt><dd>Write a <newline>.</dd><dt>...<br></dt></dl>"<br><br>So in the POSIX specs, the echo operand is not necessarily quoted, and a "\n" is SUPPOSED to be printed as a newline, unless the "-n" option is used (in which case backslash escapes are implementation specific), so according to the spec technically bash and bbox ash are non-compliant because they print the \n instead of the newline.
<br><br><p>"New applications are encouraged to use <a href="http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html"><i>printf</i></a> instead of <i>echo</i>."</p>
<h4><a name="tag_04_41_17"></a></h4>"<br><blockquote>
<p>The <i>echo</i> utility has not been made obsolescent because of its extremely widespread use in historical applications.
Conforming applications that wish to do prompting without <newline>s or that could possibly be expecting to echo a <b>-n</b>,
should use the <a href="http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html"><i>printf</i></a> utility derived from the Ninth Edition system.</p>
<p>As specified, <i>echo</i> writes its arguments in the simplest of ways. The two different historical versions of <i>echo</i>
vary in fatally incompatible ways.</p>
<p>The BSD <i>echo</i> checks the first argument for the string <b>-n</b> which causes it to suppress the <newline> that
would otherwise follow the final argument in the output.</p>
<p>The System V <i>echo</i> does not support any options, but allows escape sequences within its operands, as described for XSI
implementations in the OPERANDS section.</p>
<p>The <i>echo</i> utility does not support Utility Syntax Guideline 10 because historical applications depend on <i>echo</i> to
echo <i>all</i> of its arguments, except for the <b>-n</b> option in the BSD version.</p>
</blockquote>
<h4>"</h4><h4><a name="tag_04_41_19"></a></h4><div><span class="gmail_quote"><br>Regardless of all of this (or perhaps this is a good demonstration) - quoting is complicated and it is probably a good idea to avoid it when possible. An echo "`...`" command substitution seems a little like calling "a = strtofloat(floattostr(b));" instead of directly "a=b;"
<br><br><br>On 2/3/07, <b class="gmail_sendername">Paul Fox</b> <<a href="mailto:pgf@brightstareng.com">pgf@brightstareng.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
vapier wrote:<br> > On Saturday 03 February 2007, Brion Finlay wrote:<br> > > The fix that could be made to scripts/mkconfigs in order to work more<br> > > generally<br> ><br> > another fix would be to use a POSIX compliant shell ... then there wouldn't
<br> > be problem<br> > -mike<br> ><br><br>we had the same problem with a different build system when we<br>moved it to ubuntu. i did some googling at the time, but<br>couldn't find a definitive answer -- i expected to find a lot of
<br>discussion on it somewhere in ubuntu-land, since it's a pretty<br>big change, but i didn't. it's not clear to me that dash isn't<br>posix compliant, at least with regard to echo's expanding '\n'.
<br>but it might not be. is there a "dash is/isn't POSIX" discussion<br>page out there anywhere?<br><br>in our case it was expedient (and safe) to simply replace<br>"#!/bin/sh" with "#!/bin/bash", but that's probably not
<br>appropriate for busybox.<br><br>paul<br>=---------------------<br> paul fox, <a href="mailto:pgf@brightstareng.com">pgf@brightstareng.com</a><br>_______________________________________________<br>busybox mailing list<br>
<a href="mailto:busybox@busybox.net">busybox@busybox.net</a><br><a href="http://busybox.net/cgi-bin/mailman/listinfo/busybox">http://busybox.net/cgi-bin/mailman/listinfo/busybox</a><br></blockquote></div><br>