dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Korb <kmk@sanitarium.net>
To: Eric Blake <eblake@redhat.com>, dash@vger.kernel.org
Subject: Re: [bug?] echo -n does not work as described
Date: Wed, 11 Nov 2015 22:40:14 -0500	[thread overview]
Message-ID: <56440A1E.8070701@sanitarium.net> (raw)
In-Reply-To: <56440406.7000201@redhat.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/11/2015 10:14 PM, Eric Blake wrote:
> 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'?

I was quoting the dash man page.  I did quote the result of the
coreutils version of echo (/bin/echo) which worked correctly.

> 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.

This isn't my problem.  I am trying to use dash as a replacement for
/bin/sh and it is failing horribly.  I am not the authors of the
problem scripts.  Plus, frankly, it is absurd to require printf where
echo [-n] should work correctly according to the dash documentation.

> 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.

Either this is a bug in dash or in dash's man page.  The man page is
clear about how echo and echo -n should work.  But the reality is very
different.

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

This isn't stuff I have written.  This is stuff that I am tired of
modifying to be dash compatible.

Either dash's echo command should operate as documented or the
documentation should be corrected.

> 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.
> 

- -- 
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,
	Kevin Korb			Phone:    (407) 252-6853
	Systems Administrator		Internet:
	FutureQuest, Inc.		Kevin@FutureQuest.net  (work)
	Orlando, Florida		kmk@sanitarium.net (personal)
	Web page:			http://www.sanitarium.net/
	PGP public key available on web site.
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlZECh4ACgkQVKC1jlbQAQfK3ACeN1EC20BVyzwnSXTndBCchYS0
tHkAoKANsc2eL1imSW6u8oSpJ9VaerOc
=20HJ
-----END PGP SIGNATURE-----

  reply	other threads:[~2015-11-12  3:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12  1:56 [bug?] echo -n does not work as described Kevin Korb
2015-11-12  3:14 ` Eric Blake
2015-11-12  3:40   ` Kevin Korb [this message]
2015-11-12  3:46     ` Kevin Korb
2015-11-12  8:35       ` Seb
2015-11-12 16:12         ` Kevin Korb
2015-11-12 21:24       ` Stephane Chazelas
2015-11-12  8:10 ` Bastian Bittorf
2015-11-12 16:11   ` Kevin Korb
2015-11-19 12:36     ` Bastian Bittorf
2015-11-12 10:03 ` Petr Šabata
2015-11-12 16:18   ` Kevin Korb
2015-11-12 16:55     ` Kevin Korb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56440A1E.8070701@sanitarium.net \
    --to=kmk@sanitarium.net \
    --cc=dash@vger.kernel.org \
    --cc=eblake@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).