From unknown Fri Sep 05 08:42:18 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#14115 <14115@debbugs.gnu.org> To: bug#14115 <14115@debbugs.gnu.org> Subject: Status: [PATCH] echo: adding support for '--' in option parsing Reply-To: bug#14115 <14115@debbugs.gnu.org> Date: Fri, 05 Sep 2025 15:42:18 +0000 retitle 14115 [PATCH] echo: adding support for '--' in option parsing reassign 14115 coreutils submitter 14115 Hemmo Nieminen severity 14115 normal tag 14115 notabug patch wontfix thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 01 11:17:38 2013 Received: (at submit) by debbugs.gnu.org; 1 Apr 2013 15:17:38 +0000 Received: from localhost ([127.0.0.1]:56084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMgUM-0006PZ-97 for submit@debbugs.gnu.org; Mon, 01 Apr 2013 11:17:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45654) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMbTn-0006K7-5O for submit@debbugs.gnu.org; Mon, 01 Apr 2013 05:56:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMbO7-0006jz-6q for submit@debbugs.gnu.org; Mon, 01 Apr 2013 05:51:00 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:38619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMbO6-0006jo-Tp for submit@debbugs.gnu.org; Mon, 01 Apr 2013 05:50:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMbNm-0007RM-8m for bug-coreutils@gnu.org; Mon, 01 Apr 2013 05:50:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMbNP-0006Vr-9k for bug-coreutils@gnu.org; Mon, 01 Apr 2013 05:50:30 -0400 Received: from mail-lb0-f179.google.com ([209.85.217.179]:58205) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMbNP-0006Uk-2U for bug-coreutils@gnu.org; Mon, 01 Apr 2013 05:50:07 -0400 Received: by mail-lb0-f179.google.com with SMTP id t1so1789800lbd.38 for ; Mon, 01 Apr 2013 02:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer; bh=18YAngPze1prDmL1nTmvYu1a9aZGHNQihnkVmkgq3Jc=; b=Kqum/TIusx6DcfEa8KXnyC4zOjsDhKAzkCebcAdCj5O3Ap4IFToTdiVn2Pt5pfgvBY RVNaMnunZpSczqvFoJJLKzUOn+bwbUrDtSXhGHhMH2Ck1YKZXTs4/dTm1/pYzytGQLgI lSqsmBbiIHcdB+HyI1Ce/DypHudTBIJXyJir43veXOwD/RYvDzRxrLloYNCf0wFch4qO jYgs513Rsq5gtbtDeskNNlJLCIBQY/kHUG9Dql33ns9y02haIDGS/FdyvYcPXwySyegI E4qIZCbc3nkHVcIQNU1f/FaQC38BGoGuD/IQTlXHdZYtmaD/Iz2aXPHxYTPJR5u4ykRx 2N1g== X-Received: by 10.112.129.137 with SMTP id nw9mr5576938lbb.56.1364809805548; Mon, 01 Apr 2013 02:50:05 -0700 (PDT) Received: from fcku (dsl-hkibrasgw3-54fb7d-194.dhcp.inet.fi. [84.251.125.194]) by mx.google.com with ESMTPS id v7sm5179289lbg.13.2013.04.01.02.50.04 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Apr 2013 02:50:04 -0700 (PDT) From: Hemmo Nieminen To: bug-coreutils@gnu.org Subject: [PATCH] echo: adding support for '--' in option parsing Date: Mon, 1 Apr 2013 12:49:52 +0300 Message-Id: <1364809792-8632-1-git-send-email-hemmo.nieminen@iki.fi> X-Mailer: git-send-email 1.8.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 01 Apr 2013 11:17:36 -0400 Cc: Hemmo Nieminen X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) A '--' can now be used to mark the end of echo's options that should be parsed. This makes it possible to e.g. print lines where the first argument matches some of echo's options (e.g. 'echo -- -e'). --- src/echo.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/echo.c b/src/echo.c index 58e6975..6f76d1b 100644 --- a/src/echo.c +++ b/src/echo.c @@ -39,7 +39,7 @@ usage (int status) else { printf (_("\ -Usage: %s [SHORT-OPTION]... [STRING]...\n\ +Usage: %s [SHORT-OPTION]... [--] [STRING]...\n\ or: %s LONG-OPTION\n\ "), program_name, program_name); fputs (_("\ @@ -59,6 +59,8 @@ Echo the STRING(s) to standard output.\n\ fputs (VERSION_OPTION_DESCRIPTION, stdout); fputs (_("\ \n\ +A '--' can be used to mark the end of SHORT-OPTIONs.\n\ +\n\ If -e is in effect, the following sequences are recognized:\n\ \n\ "), stdout); @@ -149,6 +151,12 @@ main (int argc, char **argv) char const *temp = argv[0] + 1; size_t i; + if (temp[0] == '-' && temp[1] == '\0') { + argc--; + argv++; + goto just_echo; + } + /* If it appears that we are handling options, then make sure that all of the options specified are actually valid. Otherwise, the string should just be echoed. */ -- 1.8.2 From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 01 11:35:24 2013 Received: (at control) by debbugs.gnu.org; 1 Apr 2013 15:35:24 +0000 Received: from localhost ([127.0.0.1]:56136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMglY-0006rz-13 for submit@debbugs.gnu.org; Mon, 01 Apr 2013 11:35:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60482) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMglP-0006rd-7b; Mon, 01 Apr 2013 11:35:17 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r31FWKrl019181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 1 Apr 2013 11:32:20 -0400 Received: from [10.3.113.179] (ovpn-113-179.phx2.redhat.com [10.3.113.179]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r31FWKD5030932; Mon, 1 Apr 2013 11:32:20 -0400 Message-ID: <5159A883.2090704@redhat.com> Date: Mon, 01 Apr 2013 09:32:19 -0600 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: Hemmo Nieminen Subject: Re: bug#14115: [PATCH] echo: adding support for '--' in option parsing References: <1364809792-8632-1-git-send-email-hemmo.nieminen@iki.fi> In-Reply-To: <1364809792-8632-1-git-send-email-hemmo.nieminen@iki.fi> X-Enigmail-Version: 1.5.1 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2CSRWOLKEKTRRDPGMHIPM" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -7.3 (-------) X-Debbugs-Envelope-To: control Cc: control@debbugs.gnu.org, 14115-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -9.2 (---------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2CSRWOLKEKTRRDPGMHIPM Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable tag 14115 notabug wontfix thanks On 04/01/2013 03:49 AM, Hemmo Nieminen wrote: > A '--' can now be used to mark the end of echo's options that should be= > parsed. This makes it possible to e.g. print lines where the first > argument matches some of echo's options (e.g. 'echo -- -e'). Sorry, such behavior would violate POSIX, which special-cases 'echo' as one of the few utilities that MUST NOT interpret '--' specially. You would end up breaking existing scripts that rely on POSIX semantics. POSIX already admits that options to 'echo' are not portable, and that you are better off using printf(1) if then thing you need to output something that starts with a '-'. I'm closing this bug as rejected, since we will not be applying the patch; but you are free to continue discussing the issue. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2CSRWOLKEKTRRDPGMHIPM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRWaiDAAoJEKeha0olJ0Nq3CAH/16c/oBf5t6Swtfohygc1axq ChF7kXj1TPqxJ54FMEfv07pGe3IHpzYAhU6XDzq5Nqflj6LmsWJMrVReDEskvDP8 5oai7bpBZORWYhHTwKV8WaP9mxMVgacbxBL8Oz7mqrQ+HZULC1VC5go53gkyN1ux /FNLPnZPq/4ttykCusJzhkD/vWlRZiJbtO4cluRP0Q7B1LrAb+W2Jr4qB2bn0BRT ESPQLpqbV5g4NNwJn9fkyFioaaT/lTi+8otLjovhZ7gAeBnYnluBrPLs+Dkaj354 Hl1Bculi4U3VRcp3LicgI/BUCfAUC/u602mccFSdQ26T0rPU9KaYtNQjS9uhmW4= =TIDI -----END PGP SIGNATURE----- ------enig2CSRWOLKEKTRRDPGMHIPM-- From unknown Fri Sep 05 08:42:18 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 30 Apr 2013 11:24:07 +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