Re: [bug?] echo -n does not work as described

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/11/2015 06:56 PM, Kevin Korb wrote:
> I am on dash version 0.5.8.2 on Gentoo Linux (USE=libedit -static).
> 
> The echo builtin does not work as described.  In the man page:

Which man page? Coreutils'?

Read it further:

>  NOTE: your shell may have its own version of echo, which usually super‐
> sedes the version described here. Please refer to your shell's docu‐
> mentation for details about the options it supports.

By the way, 'echo -n' is non-portable, and POSIX says you should use
'printf' instead.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

    A string to be written to standard output. If the first operand is
-n, or if any of the operands contain a <backslash> character, the
results are implementation-defined.

> $ echo -n testing
> -n testing

Dash's implementation-defined behavior for -n is to treat it the same as
every other string.  Thus, this is not a bug in dash, at least according
to POSIX.

> This is causing me problems when I attempt to switch /bin/sh from bash
> to dash.

It's probably not the only bashism you've been relying on.  You may want
to try using checkbashisms
(http://sourceforge.net/projects/checkbaskisms/) to help you find other
portability pitfalls.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux