From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16818 invoked by alias); 9 Jan 2017 20:49:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40318 Received: (qmail 5787 invoked from network); 9 Jan 2017 20:49:36 -0000 X-Qmail-Scanner-Diagnostics: from mx.spodhuis.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(94.142.241.89):SA:0(-5.5/5.0):. Processed in 2.00536 secs); 09 Jan 2017 20:49:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: zsh-workers+phil.pennock@spodhuis.org X-Qmail-Scanner-Mime-Attachments: |signature.asc| X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spodhuis.org designates 94.142.241.89 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201611; h=Content-Type:MIME-Version:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3cwVhkxWRx60OY6R0mb7IeiW9cHcNNEA5o2fes/i8kc=; b=pF15h9myWwN3R+E6n3U11sUT4X Q3/I4VT72N3d1Gm06P/A4K15mmIVYItc52Af/CzQmaVrZE7T7q5a+ssqfCPz0Mhf6vVrNKWYUee/O NVMoB10TgaTiXIIgA1Ow9TBE8mh0PWBDUfRVjql4cOk/MPNzRiDfFk/UE7VA68tJ8ybnnn5NGUtPS bHn6UsTzhPI08RQQGOrvJxguK9CL; Date: Mon, 9 Jan 2017 15:32:09 -0500 From: Phil Pennock To: zsh-workers@zsh.org Subject: [PATCH] Document echo \c behaviour Message-ID: <20170109203209.GA13324@breadbox.private.spodhuis.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gKMricLos+KVdGMg" Content-Disposition: inline OpenPGP: url=https://www.security.spodhuis.org/PGP/keys/0x4D1E900E14C1CC04.asc --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Report on IRC asking about a behaviour difference between bash and zsh led me down a rabbit hole. While bash does the same thing as zsh when given "echo -e", the behaviour was not documented in our man-pages and was counter-intuitive. echo "foo\cbar" baz bat Only the "foo" is output, with no final newline. Commit logs show revision b77b51c in 2005 made this explicit, to "handle \c escapes as per POSIX (truncating the output at the \c)". SUSv4 XCU at states: > \c > Suppress the that otherwise follows the final argument in > the output. All characters following the '\c' in the arguments shall > be ignored. I think that this is worth documenting. Patch tested with "make" in Doc/ and results look fine. --- Doc/Zsh/builtins.yo | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 7b04d0648..4caefd5ba 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -453,7 +453,7 @@ tt(echo) recognizes the following escape sequences: startsitem() sitem(tt(\a))(bell character) sitem(tt(\b))(backspace) -sitem(tt(\c))(suppress final newline) +sitem(tt(\c))(suppress subsequent characters and final newline) sitem(tt(\e))(escape) sitem(tt(\f))(form feed) sitem(tt(\n))(linefeed (newline)) @@ -467,6 +467,9 @@ sitem(tt(\u)var(NNNN))(unicode character code in hexade= cimal) sitem(tt(\U)var(NNNNNNNN))(unicode character code in hexadecimal) endsitem() =20 +POSIX requires for tt(echo) that "All characters following the tt(\c) in t= he +arguments shall be ignored". + pindex(BSD_ECHO, use of) The tt(-E) flag, or the tt(BSD_ECHO) option, can be used to disable these escape sequences. In the latter case, tt(-e) flag can be used to --=20 2.11.0 --gKMricLos+KVdGMg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEExpOgNOHtbulUyuLaE9rZnH5BUZwFAlhz80gACgkQE9rZnH5B UZyGmQ/+ICYgHRxmAg5gKCq16o7HtkzYYNNM2cWfY+mSC6h9413A6MBMUGyB8uER k2f4rugBIWKFXbsYbqgTaRt2yz9NXsXA2JzohAEsfoM8t0yiOmMSem8Ag3pucNQU 3HieIm/2ztfS8pXegYKzJOEs3l9YYDMCoxIVSTKpyOhJHXzHt0WrkLjTl8B6eo7y Y1UJ4/CzHgrUVilw/sUADyD6w3a3DsV7cHFHnZo2a4O+vzODRiYLqyXpfVQdURUX GbbkzEMzEhCi+0EMEVF4QdwA+lMqcPErFVvREL/TwV5p0iAgB0VDB26KkA1huMa3 i5SPjVcED9/bHRoXsc+ilH9umsuOAp5uxue4VgxdxQq9/zun1yZbbhjwpw6E4f/b Hm5KG+q5q+hJsadotb7kn4RhA/3xI20PJM8ywLhhkbHS1grf1Z5VTHh+4smbNlqK ICrkPQ/4xrMEsNZODcRgKVyFlOE2G7e3NSQJ5k1UiWE13YJZukj2dv8NsvLj+Inb nK6pBJkx2DkGYuNdBdv3gHbTMCrlg1JLwg2X14nrhk7d7kg2YfU3i8uKts/Zvm2j xkUXMw7/HNnZ2KEMDst6COCMyQSEwmRpKlzmCXOqqdqCVSkQFcT08OEfep8LtFbC jt6/IHRvq90mQjdkm5jhSlpTdKussGFkgAxicIOUlYc32ylGUFM= =uwL1 -----END PGP SIGNATURE----- --gKMricLos+KVdGMg--