From unknown Fri Aug 15 03:38:09 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23239 <23239@debbugs.gnu.org> To: bug#23239 <23239@debbugs.gnu.org> Subject: Status: GNU echo -n argument bug Reply-To: bug#23239 <23239@debbugs.gnu.org> Date: Fri, 15 Aug 2025 10:38:09 +0000 retitle 23239 GNU echo -n argument bug reassign 23239 coreutils submitter 23239 Faissal Bensefia severity 23239 normal tag 23239 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 07 15:53:21 2016 Received: (at submit) by debbugs.gnu.org; 7 Apr 2016 19:53:22 +0000 Received: from localhost ([127.0.0.1]:53218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoFzV-0008B4-Mi for submit@debbugs.gnu.org; Thu, 07 Apr 2016 15:53:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoFap-0007ar-L5 for submit@debbugs.gnu.org; Thu, 07 Apr 2016 15:27:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoFaj-0003Fc-K9 for submit@debbugs.gnu.org; Thu, 07 Apr 2016 15:27:46 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoFaj-0003FW-Gx for submit@debbugs.gnu.org; Thu, 07 Apr 2016 15:27:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoFaj-0005E9-3M for bug-coreutils@gnu.org; Thu, 07 Apr 2016 15:27:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoFad-0003Ea-Me for bug-coreutils@gnu.org; Thu, 07 Apr 2016 15:27:44 -0400 Received: from st11p00im-asmtp001.me.com ([17.172.80.95]:49604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoFad-0003DQ-F2 for bug-coreutils@gnu.org; Thu, 07 Apr 2016 15:27:39 -0400 Received: from process-dkim-sign-daemon.st11p00im-asmtp001.me.com by st11p00im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.36.0 64bit (built Sep 8 2015)) id <0O5A00O0036RN400@st11p00im-asmtp001.me.com> for bug-coreutils@gnu.org; Thu, 07 Apr 2016 19:27:35 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-04-07_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=5 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1604070273 Received: from [192.168.0.3] (cpc11-lewi16-2-0-cust458.2-4.cable.virginm.net [82.23.5.203]) by st11p00im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.36.0 64bit (built Sep 8 2015)) with ESMTPSA id <0O5A00M5M3DSU240@st11p00im-asmtp001.me.com> for bug-coreutils@gnu.org; Thu, 07 Apr 2016 19:27:29 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-04-07_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=5 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1604070273 To: bug-coreutils@gnu.org From: Faissal Bensefia Subject: GNU echo -n argument bug X-Enigmail-Draft-Status: N1110 Message-id: <5706B49F.4070700@me.com> Date: Thu, 07 Apr 2016 20:27:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a; t=1460057255; bh=HZyAHvdl1Fb+pL2TdrM64TeWgix3J8I7k0+svkhakGo=; h=To:From:Subject:Message-id:Date:MIME-version:Content-type; b=XQJGyPhNUQk2XzEVMQ1Zhln/2HqBdCtV9EHRVw370XSrtnHNecGn/MYSC7yAgrtNS y9ltQLmdv6F14b53k/1xRDLz8E+zVWHC+FK5DrebZw92ajVs0cD+VoA/Ywxt2bOW1B pwYgaqtAYoNWNceoGAev9zF/Qborp4MBr6WK1r1Ve1cxPzFzMeu8u+Twx7kaZU7uqs rXdo1vE3cnLdDhEdl6SQQVITH7iweOEh2q646opRYaabhEyDFYBcyeEuMvzPdjzDb6 hWuip1wmaYNXFHE/lk/7rTkGswF36Tnd5CkFajrep/7WIWP6qMjVZrMrHxusktZVqO ZNckq6xfAEOgw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 07 Apr 2016 15:53:20 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hey, I stumbled across a bug in GNU coreutils' echo, if I use echo with an option like -nn or -nnnnnnn it should be treated as something echoable and echo "-nnnnnnn\n" but it doesn't, instead it takes it as an -n argument and just doesn't echo with a newline. If I were to however put a character that is not an 'n' in the long string of ns it does echo it as it should. Thank you for your time, ~Faissal Bensefia From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 07 18:30:41 2016 Received: (at control) by debbugs.gnu.org; 7 Apr 2016 22:30:42 +0000 Received: from localhost ([127.0.0.1]:53300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoIRl-0003Sy-Jy for submit@debbugs.gnu.org; Thu, 07 Apr 2016 18:30:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoIRj-0003Sf-Lm; Thu, 07 Apr 2016 18:30:40 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0ECB646201; Thu, 7 Apr 2016 22:30:34 +0000 (UTC) Received: from [10.3.113.199] (ovpn-113-199.phx2.redhat.com [10.3.113.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u37MUXEh000997; Thu, 7 Apr 2016 18:30:33 -0400 Subject: Re: bug#23239: GNU echo -n argument bug To: Faissal Bensefia , 23239-done@debbugs.gnu.org, GNU bug control References: <5706B49F.4070700@me.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <5706DF89.5010102@redhat.com> Date: Thu, 7 Apr 2016 16:30:33 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <5706B49F.4070700@me.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8HinMCBg2hGfa9ACdB76MUMsJ6b9wqXbv" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8HinMCBg2hGfa9ACdB76MUMsJ6b9wqXbv Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tag 23239 notabug thanks On 04/07/2016 01:27 PM, Faissal Bensefia wrote: > Hey, > I stumbled across a bug in GNU coreutils' echo, if I use echo with an > option like -nn or -nnnnnnn it should be treated as something echoable > and echo "-nnnnnnn\n" but it doesn't, instead it takes it as an -n > argument and just doesn't echo with a newline. If I were to however put= > a character that is not an 'n' in the long string of ns it does echo it= > as it should. POSIX says it is not portable to use 'echo' with ANY string that starts with '-': http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html and that you should favor printf instead. Furthermore, it states that the magic -n option (which has implementation-defined behavior) MUST be spelled exactly '-n' (and not '-nnnn'), to trigger the XSI behavior. Any other spelling has undefined results. So in coreutils, we've taken the following approach: by default, parse the options the same way getopt() always does; ANY sequence of options is treated as that option. In your case, you get the same as if you had specified multiple '-n' options: $ /bin/echo -nnn hi | od -tx1 -An 68 69 But if you don't like the default, then ask for POSIX compliance: $ POSIXLY_CORRECT=3D1 /bin/echo -nnn hi | od -tx1 -An 2d 6e 6e 6e 20 68 69 0a where we explicitly honor EXACTLY '-n'. As such, I don't see any problem with our current behavior, and am closing out this bug report. But feel free to add further comments. Also, there's a big long thread recently in the Austin Group: http://thread.gmane.org/gmane.comp.standards.posix.austin.general/12097 which concludes that POSIX is probably over-strict (by requiring exactly '-n', it forbids the relatively common '-e', '-E' and even '-ne' or '-en' options), but that changing the wording is an uphill battle: > echo "---- cut here ----" is perfectly safe and the standard > should not be changed to imply that it is not safe. For this > reason, I believe there is zero chance that Robert's wording > will achieve consensus. To be accepted, the new wording will > need to add only a narrow set of cases to the implementation- > defined behaviour. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --8HinMCBg2hGfa9ACdB76MUMsJ6b9wqXbv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXBt+JAAoJEKeha0olJ0Nq2hMH/3v/3wA9MqoKRSJIu46hvsbI aWN1W5Om8DQ4Scouj/PuX6Lh1/7TBya9p1lVB/l5y2tSKyDSOevzcqsaHGza8kas Rlh/hhZTYvg8daddPOOoxocTnPWTiDizf4eblUNqJLK8yK4bm8YRUnBtSf9zrj+t EeMkYEwLgA9y0Shi07rZl5aAAfMBHsFgBavzgh+711fdKuEOV5He7DUrm945PtI0 wNqkw0aNrGNAf2DbOoUIN/SoeUxDffZDS92YZfli3ebqWsipEuc3+1s3ZR6A/r9H Ko2+3UsCAcRYygU5iWRJpReezycEMzHbmHql/39aq7gNCS+SQvYwcY13QaHbYRU= =IG2P -----END PGP SIGNATURE----- --8HinMCBg2hGfa9ACdB76MUMsJ6b9wqXbv-- From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 08 02:15:17 2016 Received: (at 23239) by debbugs.gnu.org; 8 Apr 2016 06:15:17 +0000 Received: from localhost ([127.0.0.1]:53384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoPhN-0007Uf-Jn for submit@debbugs.gnu.org; Fri, 08 Apr 2016 02:15:17 -0400 Received: from mout.gmx.net ([212.227.15.19]:59326) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoPhL-0007UQ-PH for 23239@debbugs.gnu.org; Fri, 08 Apr 2016 02:15:16 -0400 Received: from tenfore.site ([95.114.252.129]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0M24ap-1bgeHF1LQp-00u3Qp; Fri, 08 Apr 2016 08:15:02 +0200 From: Ruediger Meier To: 23239@debbugs.gnu.org, eblake@redhat.com, faissaloo@me.com Subject: Re: bug#23239: GNU echo -n argument bug Date: Fri, 8 Apr 2016 08:15:00 +0200 User-Agent: KMail/1.9.10 References: <5706B49F.4070700@me.com> <5706DF89.5010102@redhat.com> In-Reply-To: <5706DF89.5010102@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201604080815.01071.sweet_f_a@gmx.de> X-Provags-ID: V03:K0:UHkHQPkROCV+VuBXMTu9dJkzc6BMk2/X9Yc3Hcjiak3ykQ+Y/3d LklYEZw7+ATrAxCTagdcCtPeDmbbnnpLG6MArwt5zohgB77TuF4/bI+6syCRPErl+JX+KBW yqOdiZyNGlAwO2FkbbZdXBbkqGMJl06YYAEOC3vpX21fipUgQeviB1QQyTxRBDEizBibyaY m6OjFrEcWcbYAnfJeRUng== X-UI-Out-Filterresults: notjunk:1;V01:K0:s9/0ydwGYt0=:5UXv58LrId3XXt+jYOBf7n nbiCG20qOqmMyUMNIPwNh0u+1vw24iYD8FQsbFHhe9C2VFOlgCBsSJ0DiEubgvA2ESFfF1G1Z 7ZwL1rJlE91zzMj89CoZ5hwVgoPjgMkuOPje5zT269KAWSH/eRK6yl9MrE34jj6JFZWlVox1C W4tU+/5t29xtvj/Sjvkb8dTZZyNnhND5K8hLUe3GOHGEx5t+9tBqjF9t8c2ik3EEtNEiTKqdT LT7fGS7M1G9PzQst5X7RX2WJvRCJoJL/XtkeKgLmzsLMA93+/2TdiZoEmvNo+4fC1FOwJ/4Kv /aAIUwd68vz9RYq9cX4l7UoZqnwz6cvj/BQqvDurgWSJrUjU4cuGhR0AfmoILhkX4G//wgmN5 yIKKbW4uLYoL+Q2fPpN9wVMByOaUCg8kNDPpZE5b38SFjTo6mio7n3+RVk7w+lJVaQN4D/kPw vM7a8coVxtNoIPkj/PcIatSEh0Y+nvzpx7QlQPdElzvG0TYVmE53uAiWF/KVlyL89iFu9FpZh GpZFYa92UfMcY3+LD5vdQUxUkNfLJzjQnYEJt6c/JQU43tjIibCEf8wOR9yyqGrUSaMYjsIea 2Hwtig90C04Y1d4nsxkYf9Te6RyUpVlEqQxUJ5FTZGc9Qz3fvTkWXSoMZaRYibFU8mqk9zxnw U9MazPjjIYl/kVP1HaUFD7+xbaBkCIttwc+owrFiY0Lv1fzjl11RnEKygiN8XUBv13SH9VyeQ mpLO3BnzgaW40Z/jER/atlUy4nO64R2jlJgCTwTaG1dBW/HAgL15C3sgn3M= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 23239 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Friday 08 April 2016, Eric Blake wrote: > tag 23239 notabug > thanks > > On 04/07/2016 01:27 PM, Faissal Bensefia wrote: > > Hey, > > I stumbled across a bug in GNU coreutils' echo, if I use echo with > > an option like -nn or -nnnnnnn it should be treated as something > > echoable and echo "-nnnnnnn\n" but it doesn't, instead it takes it > > as an -n argument and just doesn't echo with a newline. If I were > > to however put a character that is not an 'n' in the long string of > > ns it does echo it as it should. > > POSIX says it is not portable to use 'echo' with ANY string that > starts with '-': > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html Could you please point me to the exact sentence where they mention "ANY string that starts with "-"? I see only notes about "-n". > and that you should favor printf instead. > > Furthermore, it states that the magic -n option (which has > implementation-defined behavior) MUST be spelled exactly '-n' (and > not '-nnnn'), to trigger the XSI behavior. Any other spelling has > undefined results. > > So in coreutils, we've taken the following approach: by default, > parse the options the same way getopt() always does; ANY sequence of > options is treated as that option. In your case, you get the same as > if you had specified multiple '-n' options: > > $ /bin/echo -nnn hi | od -tx1 -An > 68 69 > > But if you don't like the default, then ask for POSIX compliance: > > $ POSIXLY_CORRECT=1 /bin/echo -nnn hi | od -tx1 -An > 2d 6e 6e 6e 20 68 69 0a > > where we explicitly honor EXACTLY '-n'. > > As such, I don't see any problem with our current behavior, and am > closing out this bug report. But feel free to add further comments. > > Also, there's a big long thread recently in the Austin Group: > http://thread.gmane.org/gmane.comp.standards.posix.austin.general/120 >97 > > which concludes that POSIX is probably over-strict (by requiring > exactly '-n', it forbids the relatively common '-e', '-E' and even > '-ne' or And probably it's also "over-strict" to forbid GNU coreutils' uniq options --help and --version ... which makes it even incompatible to GNU bash. > '-en' options), but that changing the wording is an uphill battle: > > echo "---- cut here ----" is perfectly safe and the standard > > should not be changed to imply that it is not safe. For this > > reason, I believe there is zero chance that Robert's wording > > will achieve consensus. To be accepted, the new wording will > > need to add only a narrow set of cases to the implementation- > > defined behaviour. From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 08 09:40:55 2016 Received: (at 23239) by debbugs.gnu.org; 8 Apr 2016 13:40:55 +0000 Received: from localhost ([127.0.0.1]:53663 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoWec-0002aa-Pz for submit@debbugs.gnu.org; Fri, 08 Apr 2016 09:40:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41148) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoWea-0002a8-3Z for 23239@debbugs.gnu.org; Fri, 08 Apr 2016 09:40:54 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6200ED273; Fri, 8 Apr 2016 13:40:41 +0000 (UTC) Received: from [10.3.113.199] (ovpn-113-199.phx2.redhat.com [10.3.113.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u38DeeTD009758; Fri, 8 Apr 2016 09:40:40 -0400 Subject: Re: bug#23239: GNU echo -n argument bug To: Ruediger Meier , 23239@debbugs.gnu.org, faissaloo@me.com References: <5706B49F.4070700@me.com> <5706DF89.5010102@redhat.com> <201604080815.01071.sweet_f_a@gmx.de> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <5707B4D7.2@redhat.com> Date: Fri, 8 Apr 2016 07:40:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <201604080815.01071.sweet_f_a@gmx.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FcxToWdiCw275DSxk1hLED75WdRmh0p2d" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 08 Apr 2016 13:40:42 +0000 (UTC) X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: 23239 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FcxToWdiCw275DSxk1hLED75WdRmh0p2d Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/08/2016 12:15 AM, Ruediger Meier wrote: > On Friday 08 April 2016, Eric Blake wrote: >> tag 23239 notabug >> thanks >> >> On 04/07/2016 01:27 PM, Faissal Bensefia wrote: >>> Hey, >>> I stumbled across a bug in GNU coreutils' echo, if I use echo with >>> an option like -nn or -nnnnnnn it should be treated as something >>> echoable and echo "-nnnnnnn\n" but it doesn't, instead it takes it >>> as an -n argument and just doesn't echo with a newline. If I were >>> to however put a character that is not an 'n' in the long string of >>> ns it does echo it as it should. >> >> POSIX says it is not portable to use 'echo' with ANY string that >> starts with '-': >> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html >=20 > Could you please point me to the exact sentence where they mention "ANY= =20 > string that starts with "-"? I see only notes about "-n". " The echo utility shall not recognize the "--" argument in the manner specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall be recognized as a string operand. Implementations shall not support any options. string A string to be written to standard output. If the first operand is -n, or if any of the operands contain a character, the results are implementation-defined. " Okay, so it doesn't forbid ANY string starting with -, only that such strings are not options. But coreutils' behavior definitely falls under the POSIX discussion I mentioned earlier: >> >> Also, there's a big long thread recently in the Austin Group: >> http://thread.gmane.org/gmane.comp.standards.posix.austin.general/120 >> 97 >> >> which concludes that POSIX is probably over-strict (by requiring >> exactly '-n', it forbids the relatively common '-e', '-E' and even >> '-ne' or There's certainly a possibility that someone may propose wording to make POSIX cater to existing implementations, and their various quirks. >=20 > And probably it's also "over-strict" to forbid GNU coreutils' uniq=20 > options --help and --version ... which makes it even incompatible to=20 > GNU bash. Coreutils complies with POSIX here: $ /bin/echo --help | head -n1 Usage: /bin/echo [SHORT-OPTION]... [STRING]... $ POSIXLY_CORRECT=3D1 /bin/echo --help --help When you ask for POSIX compliance, coreutils treats --help as a literal string, exactly as required in the current wording. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --FcxToWdiCw275DSxk1hLED75WdRmh0p2d Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXB7TXAAoJEKeha0olJ0Nqp3wH/i7q5lqzcLpZcNRsk8iI54d3 +0S9eXj6tHWlrQDw3In4awZaFNnDwtsM0o81cYauYB8nfs7E68d3UWSSiEfxQgCn mf9Bv+6zEt/SOLzAMTBqAwL5LF+Njgcen/8kn3XJ9hyd5OrsIC30rkRCH38hPuuA ifWQvP8BXkkCcKwLvfAs5B6lhDTZLAdMxcRs0PNeBNdZCPDmRopbG8n2p9MhptLI 2/2iXDG+2th6WmNv5eWAz46Hq/cO22BSE93iRlXR5bxsj4vZsHYNIAEHhG9DlbNC zo4qBqO/muAvhjschMkSB5DZEHtcl1Lf2q0Tvy0WieGmb1wQBq49anrh+KqvEpk= =dz9v -----END PGP SIGNATURE----- --FcxToWdiCw275DSxk1hLED75WdRmh0p2d-- From unknown Fri Aug 15 03:38:09 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 07 May 2016 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator