From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 20:52:42 2011 Received: (at submit) by debbugs.gnu.org; 9 Dec 2011 01:52:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RYpdh-0008JV-1r for submit@debbugs.gnu.org; Thu, 08 Dec 2011 20:52:42 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RYpde-0008JN-2D for submit@debbugs.gnu.org; Thu, 08 Dec 2011 20:52:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYpcm-0001GY-Sx for submit@debbugs.gnu.org; Thu, 08 Dec 2011 20:51:45 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:42759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYpcm-0001GU-RT for submit@debbugs.gnu.org; Thu, 08 Dec 2011 20:51:44 -0500 Received: from eggs.gnu.org ([140.186.70.92]:37632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYpcl-0002Qy-Tu for bug-coreutils@gnu.org; Thu, 08 Dec 2011 20:51:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYpck-0001GI-PH for bug-coreutils@gnu.org; Thu, 08 Dec 2011 20:51:43 -0500 Received: from caiajhbdcahe.dreamhost.com ([208.97.132.74]:38358 helo=homiemail-a62.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYpck-0001Fv-GK for bug-coreutils@gnu.org; Thu, 08 Dec 2011 20:51:42 -0500 Received: from homiemail-a62.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTP id EEAF263406F for ; Thu, 8 Dec 2011 17:51:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=jidanni.org ; b=PBGh4+8UefU/0DhCUQf4UJW/+I5n7EMYpFdsJ9e7w48FauolvXle04iV4eX3 eXEKi7cSxS228IVkI6wrpglqAHc3+kRAzAHaoCpcakPHkCHHOGcyS7xeEWPRA4v/ rgeMEP+/diUAvwWD83iIR3/gop/SBH8yF4QetPOWWBktn4Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type; s= jidanni.org; bh=txbOUsDYIceJrglg+B4a0yyfnJ0=; b=Wo/Pjm/NxTmGN9N5 C6+jS6eOPBpsIVKK2M2Fu55JXsLZZCIzV2Ud4oMxZNcy33apTE4vK3JiZdsFdk51 o9fN/RW0Lr8wTwF7++sWZSUlhSzzyhx0INz/N4iGdMnFhYMiCI8jaivHgnPwK5y/ mMOSnWStyFeoLAi1AVe80mgXVwY= Received: from jidanni.org (218-163-22-69.dynamic.hinet.net [218.163.22.69]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTPSA id A015F63406C for ; Thu, 8 Dec 2011 17:51:40 -0800 (PST) From: jidanni@jidanni.org To: bug-coreutils@gnu.org Subject: mention +FORMAT in ls time style reminder help blurb Date: Fri, 09 Dec 2011 09:51:37 +0800 Message-ID: <87obvi8qc6.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.4 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -5.4 (-----) $ ls -t1 --time-style=%c -og ls: invalid argument `%c' for `time style' Valid arguments are: - `full-iso' - `long-iso' - `iso' - `locale' <-------------you forgot to also mention "+FORMAT" Try `ls --help' for more information. $ ls -t1 --time-style=+%c -og From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 14:23:25 2011 Received: (at 10253) by debbugs.gnu.org; 9 Dec 2011 19:23:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZ62W-0000IQ-E4 for submit@debbugs.gnu.org; Fri, 09 Dec 2011 14:23:25 -0500 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZ62T-0000IG-VJ for 10253@debbugs.gnu.org; Fri, 09 Dec 2011 14:23:23 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id D386560023; Fri, 9 Dec 2011 20:22:24 +0100 (CET) From: Jim Meyering To: jidanni@jidanni.org Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb In-Reply-To: <87obvi8qc6.fsf@jidanni.org> (jidanni@jidanni.org's message of "Fri, 09 Dec 2011 09:51:37 +0800") References: <87obvi8qc6.fsf@jidanni.org> Date: Fri, 09 Dec 2011 20:22:24 +0100 Message-ID: <87liqlk0sv.fsf@rho.meyering.net> Lines: 19 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -2.7 (--) jidanni@jidanni.org wrote: > $ ls -t1 --time-style=%c -og > ls: invalid argument `%c' for `time style' > Valid arguments are: > - `full-iso' > - `long-iso' > - `iso' > - `locale' <-------------you forgot to also mention "+FORMAT" > Try `ls --help' for more information. > $ ls -t1 --time-style=+%c -og Thanks for the report. However, that doesn't lend itself well to a clean fix, since +FORMAT is not a literal string option argument like the others, and currently that diagnostic is generated automatically based on the list of literal strings. I'm inclined to leave it as-is. Any other opinions? From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 16:31:19 2011 Received: (at 10253) by debbugs.gnu.org; 9 Dec 2011 21:31:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZ82I-0003FT-6U for submit@debbugs.gnu.org; Fri, 09 Dec 2011 16:31:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZ82D-0003FJ-K9 for 10253@debbugs.gnu.org; Fri, 09 Dec 2011 16:31:16 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB9LUFAN023771 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 9 Dec 2011 16:30:15 -0500 Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pB9LUEDW022511; Fri, 9 Dec 2011 16:30:14 -0500 Message-ID: <4EE27DE6.60209@redhat.com> Date: Fri, 09 Dec 2011 14:30:14 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb References: <87obvi8qc6.fsf@jidanni.org> <87liqlk0sv.fsf@rho.meyering.net> In-Reply-To: <87liqlk0sv.fsf@rho.meyering.net> X-Enigmail-Version: 1.3.3 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig44D78AA2C825226036E17D40" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, jidanni@jidanni.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -10.3 (----------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig44D78AA2C825226036E17D40 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/09/2011 12:22 PM, Jim Meyering wrote: > jidanni@jidanni.org wrote: >> $ ls -t1 --time-style=3D%c -og >> ls: invalid argument `%c' for `time style' >> Valid arguments are: >> - `full-iso' >> - `long-iso' >> - `iso' >> - `locale' <-------------you forgot to also mention "+FORMAT" >> Try `ls --help' for more information. >> $ ls -t1 --time-style=3D+%c -og >=20 > Thanks for the report. > However, that doesn't lend itself well to a clean fix, since +FORMAT > is not a literal string option argument like the others, and currently > that diagnostic is generated automatically based on the list of literal= strings. I agree that listing `+FORMAT' doesn't fit the pattern. But maybe we can make it obvious that there is a non-literal possibility, as well as also mentioning the posix- prefix already covered by 'ls --help': Valid arguments are: - `[posix-]full-iso' - `[posix-]long-iso' - `[posix-]iso' - `[posix-]locale' - `+' followed by formatting directives Try `ls --help' for more information. Also, I noticed that 'ls --help' uses FORMAT in the text for --time-style, but doesn't define FORMAT anywhere else; we probably ought to have a one-line sentence at the bottom, after the paragraph on SIZE, stating: See `date --help' for valid directives that may appear in FORMAT. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig44D78AA2C825226036E17D40 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.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJO4n3mAAoJEKeha0olJ0NqTDkH/0ia5H+j6damrLsHQViMgYJu ETqaGVjuFotrVOlvRAk+pfFPZZToShYWUtD81qo1HEqrN0zTqrOBI7ZZDR7ApmEC l6TVpIoJgejVs603xYhk7GjmvKPgHzVxnGHXEKgXgrl9OBrycCwAJsTh6+QINjg2 A19R/XiPY8FEZoyjF6QoofpzeDXy7KAScePB6THHQeIbhsCw79IQ/yX/m3i443Ro SEpZD0zd2SeYfBCcbuy4BrGL6okQnIwAV0aIA5Es1Tw3YQ84CXchZdAFdJqKJm6U b+mkhfY2z6ztVG8RnJD1VAGpNgmgOk587LX7xMFoBMnZLwE5BPv4O6ZOt/qjcNw= =r6Vo -----END PGP SIGNATURE----- --------------enig44D78AA2C825226036E17D40-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 12:30:34 2011 Received: (at 10253) by debbugs.gnu.org; 10 Dec 2011 17:30:34 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZQks-0001TT-J0 for submit@debbugs.gnu.org; Sat, 10 Dec 2011 12:30:34 -0500 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZQkq-0001TL-5r for 10253@debbugs.gnu.org; Sat, 10 Dec 2011 12:30:33 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id B435C60092; Sat, 10 Dec 2011 18:29:29 +0100 (CET) From: Jim Meyering To: Eric Blake Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb In-Reply-To: <4EE27DE6.60209@redhat.com> (Eric Blake's message of "Fri, 09 Dec 2011 14:30:14 -0700") References: <87obvi8qc6.fsf@jidanni.org> <87liqlk0sv.fsf@rho.meyering.net> <4EE27DE6.60209@redhat.com> Date: Sat, 10 Dec 2011 18:29:29 +0100 Message-ID: <87fwgse3nq.fsf@rho.meyering.net> Lines: 57 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, jidanni@jidanni.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -2.7 (--) Eric Blake wrote: > On 12/09/2011 12:22 PM, Jim Meyering wrote: >> jidanni@jidanni.org wrote: >>> $ ls -t1 --time-style=%c -og >>> ls: invalid argument `%c' for `time style' >>> Valid arguments are: >>> - `full-iso' >>> - `long-iso' >>> - `iso' >>> - `locale' <-------------you forgot to also mention "+FORMAT" >>> Try `ls --help' for more information. >>> $ ls -t1 --time-style=+%c -og >> >> Thanks for the report. >> However, that doesn't lend itself well to a clean fix, since +FORMAT >> is not a literal string option argument like the others, and currently >> that diagnostic is generated automatically based on the list of literal strings. > > I agree that listing `+FORMAT' doesn't fit the pattern. But maybe we > can make it obvious that there is a non-literal possibility, as well as > also mentioning the posix- prefix already covered by 'ls --help': > > Valid arguments are: > - `[posix-]full-iso' > - `[posix-]long-iso' > - `[posix-]iso' > - `[posix-]locale' > - `+' followed by formatting directives > Try `ls --help' for more information. Sure, that is possible, and adding the [posix-] prefixes would be a nice bonus. The trouble is that the current code is not only nice and compact, but will safely and automatically reflect any addition to the list of time styles: switch (XARGMATCH ("time style", style, time_style_args, time_style_types)) That handles everything, including printing the offending diagnostic and exiting. If you pick it apart in preparation for open-coding, you then have to find a way to ensure that the new diagnostic stays in sync with list of possible option arguments. All feasible, but is it worth it, just for an improved diagnostic that won't be seen unless you use ls's --time-style=V option with an invalid V ? I'm leaning away, but if someone comes up with a clean and maintainable way to do it, no problem. > Also, I noticed that 'ls --help' uses FORMAT in the text for > --time-style, but doesn't define FORMAT anywhere else; we probably ought > to have a one-line sentence at the bottom, after the paragraph on SIZE, > stating: > > See `date --help' for valid directives that may appear in FORMAT. Good idea. Patch most welcome. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 19:03:23 2011 Received: (at 10253) by debbugs.gnu.org; 11 Dec 2011 00:03:23 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZWt0-0004Mx-Bq for submit@debbugs.gnu.org; Sat, 10 Dec 2011 19:03:23 -0500 Received: from caiajhbdcaid.dreamhost.com ([208.97.132.83] helo=homiemail-a62.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZWsx-0004Mp-09 for 10253@debbugs.gnu.org; Sat, 10 Dec 2011 19:03:20 -0500 Received: from homiemail-a62.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTP id D2BC563406E; Sat, 10 Dec 2011 16:02:14 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:cc:subject :references:date:message-id:mime-version:content-type; q=dns; s= jidanni.org; b=OlwO1RL4Dn4Bck8w7atPiKjHzxiIQ9yukHknufKsmUR2rypRq 4QWpCw1HmiBFesOhFoGS8zTfFyOvnCiCFVhtmFn08DiOKdoUM8IjrARPGWxTTSkZ F2drsnanX05AAV9huIyNTajj5vZxTW/3U/gnXq3RA1Znpw40YA9dteIpO8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=PtP5eZwNd1ZobxvOKxKAbeuU0mU=; b=UFT7SvXjNYK+8 Cxvyh0J9vw7SSpK//fSNe2bONlYAL2FaJ/6TUqyWsTpDBXL3lCCXCtwEn1xCkkY2 Z+b7Fc3w9+3NtK9cCCMhwAfDGal6VMzeioIZM+xq8cvICq/xFdQnGp3EwBQDpPKL 82tTOkOFSv36im6Qi6qcYuAzleKPhQ= Received: from jidanni.org (218-163-22-30.dynamic.hinet.net [218.163.22.30]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTPSA id 83B5D634064; Sat, 10 Dec 2011 16:02:14 -0800 (PST) From: jidanni@jidanni.org To: jim@meyering.net Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb References: <87fwgse3nq.fsf@rho.meyering.net> Date: Sun, 11 Dec 2011 08:02:11 +0800 Message-ID: <8739csgem4.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, eblake@redhat.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -3.4 (---) Well wherever you say 4/5ths of something that means the other 1/5th does not exist, so it would be better to say nothing. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 06:08:19 2011 Received: (at 10253) by debbugs.gnu.org; 11 Dec 2011 11:08:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZhGU-0004qv-FB for submit@debbugs.gnu.org; Sun, 11 Dec 2011 06:08:19 -0500 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZhGR-0004qc-1n for 10253@debbugs.gnu.org; Sun, 11 Dec 2011 06:08:17 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 46C0A60404; Sun, 11 Dec 2011 12:07:08 +0100 (CET) From: Jim Meyering To: Eric Blake Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb In-Reply-To: <87fwgse3nq.fsf@rho.meyering.net> (Jim Meyering's message of "Sat, 10 Dec 2011 18:29:29 +0100") References: <87obvi8qc6.fsf@jidanni.org> <87liqlk0sv.fsf@rho.meyering.net> <4EE27DE6.60209@redhat.com> <87fwgse3nq.fsf@rho.meyering.net> Date: Sun, 11 Dec 2011 12:07:08 +0100 Message-ID: <87k463bc4j.fsf@rho.meyering.net> Lines: 222 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, jidanni@jidanni.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -2.7 (--) Jim Meyering wrote: > Eric Blake wrote: >> On 12/09/2011 12:22 PM, Jim Meyering wrote: >>> jidanni@jidanni.org wrote: >>>> $ ls -t1 --time-style=%c -og >>>> ls: invalid argument `%c' for `time style' >>>> Valid arguments are: >>>> - `full-iso' >>>> - `long-iso' >>>> - `iso' >>>> - `locale' <-------------you forgot to also mention "+FORMAT" >>>> Try `ls --help' for more information. >>>> $ ls -t1 --time-style=+%c -og >>> >>> Thanks for the report. >>> However, that doesn't lend itself well to a clean fix, since +FORMAT >>> is not a literal string option argument like the others, and currently >>> that diagnostic is generated automatically based on the list of >>> literal strings. >> >> I agree that listing `+FORMAT' doesn't fit the pattern. But maybe we >> can make it obvious that there is a non-literal possibility, as well as >> also mentioning the posix- prefix already covered by 'ls --help': >> >> Valid arguments are: >> - `[posix-]full-iso' >> - `[posix-]long-iso' >> - `[posix-]iso' >> - `[posix-]locale' >> - `+' followed by formatting directives >> Try `ls --help' for more information. > > Sure, that is possible, and adding the [posix-] prefixes would be a nice bonus. > The trouble is that the current code is not only nice and compact, but will > safely and automatically reflect any addition to the list of time styles: > > switch (XARGMATCH ("time style", style, > time_style_args, > time_style_types)) > > That handles everything, including printing the offending diagnostic > and exiting. If you pick it apart in preparation for open-coding, you > then have to find a way to ensure that the new diagnostic stays in sync > with list of possible option arguments. > > All feasible, but is it worth it, just for an improved diagnostic that > won't be seen unless you use ls's --time-style=V option with an invalid V ? > > I'm leaning away, but if someone comes up with a clean and > maintainable way to do it, no problem. I went ahead and started writing, to see just how bad it would be... This looks worse than it is due to the indentation change. Below is the much smaller white-space-ignoring diff. It seems worthwhile after all. With this patch, ls would print this: $ src/ls -l --time-style=%c src/ls: invalid argument `%c' for `time style' Valid arguments are: - `[posix-]full-iso' - `[posix-]long-iso' - `[posix-]iso' - `[posix-]locale' - `+' followed by a date format string Try `src/ls --help' for more information. >From 4114b1c0e1116e05d50ea3a2377edfb8bb090e78 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 11 Dec 2011 11:59:31 +0100 Subject: [PATCH] ls: give a more useful diagnostic for a bogus --time-style arg * src/ls.c (decode_switches): Replace our use of XARGMATCH with open-coded version so that we can give a better diagnostic. Reported by Dan Jacobson in http://bugs.gnu.org/10253 --- src/ls.c | 72 +++++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/ls.c b/src/ls.c index 0d64bab..ac01f3d 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2039,33 +2039,57 @@ decode_switches (int argc, char **argv) long_time_format[1] = p1; } else - switch (XARGMATCH ("time style", style, - time_style_args, - time_style_types)) - { - case full_iso_time_style: - long_time_format[0] = long_time_format[1] = - "%Y-%m-%d %H:%M:%S.%N %z"; - break; + { + ptrdiff_t res = argmatch (style, time_style_args, + (char const *) time_style_types, + sizeof (*time_style_types)); + if (res < 0) + { + /* This whole block used to be a simple use of XARGMATCH. + but that didn't print the "posix-"-prefixed variants or + the "+"-prefixed format string option upon failure. */ + argmatch_invalid ("time style", style, res); + + /* The following is a manual expansion of argmatch_valid, + but with the added "+ ..." description and the [posix-] + prefixes prepended. Note that this simplification works + only because all four existing time_style_types values + are distinct. */ + fprintf (stderr, _("Valid arguments are:")); + char const *const *p = time_style_args; + while (*p) + fprintf (stderr, " - `[posix-]%s'\n", *p++); + fprintf (stderr, + _(" - `+' followed by a date format string\n")); + usage (LS_FAILURE); + } + switch (res) + { + case full_iso_time_style: + long_time_format[0] = long_time_format[1] = + "%Y-%m-%d %H:%M:%S.%N %z"; + break; - case long_iso_time_style: - long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; - break; + case long_iso_time_style: + long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; + break; - case iso_time_style: - long_time_format[0] = "%Y-%m-%d "; - long_time_format[1] = "%m-%d %H:%M"; - break; + case iso_time_style: + long_time_format[0] = "%Y-%m-%d "; + long_time_format[1] = "%m-%d %H:%M"; + break; + + case locale_time_style: + if (hard_locale (LC_TIME)) + { + int i; + for (i = 0; i < 2; i++) + long_time_format[i] = + dcgettext (NULL, long_time_format[i], LC_TIME); + } + } + } - case locale_time_style: - if (hard_locale (LC_TIME)) - { - int i; - for (i = 0; i < 2; i++) - long_time_format[i] = - dcgettext (NULL, long_time_format[i], LC_TIME); - } - } /* Note we leave %5b etc. alone so user widths/flags are honored. */ if (strstr (long_time_format[0], "%b") || strstr (long_time_format[1], "%b")) -- 1.7.8.163.g9859a Ignoring white space changes: diff --git a/src/ls.c b/src/ls.c index 0d64bab..ac01f3d 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2039,9 +2039,31 @@ decode_switches (int argc, char **argv) long_time_format[1] = p1; } else - switch (XARGMATCH ("time style", style, - time_style_args, - time_style_types)) + { + ptrdiff_t res = argmatch (style, time_style_args, + (char const *) time_style_types, + sizeof (*time_style_types)); + if (res < 0) + { + /* This whole block used to be a simple use of XARGMATCH. + but that didn't print the "posix-"-prefixed variants or + the "+"-prefixed format string option upon failure. */ + argmatch_invalid ("time style", style, res); + + /* The following is a manual expansion of argmatch_valid, + but with the added "+ ..." description and the [posix-] + prefixes prepended. Note that this simplification works + only because all four existing time_style_types values + are distinct. */ + fprintf (stderr, _("Valid arguments are:")); + char const *const *p = time_style_args; + while (*p) + fprintf (stderr, " - `[posix-]%s'\n", *p++); + fprintf (stderr, + _(" - `+' followed by a date format string\n")); + usage (LS_FAILURE); + } + switch (res) { case full_iso_time_style: long_time_format[0] = long_time_format[1] = @@ -2066,6 +2088,8 @@ decode_switches (int argc, char **argv) dcgettext (NULL, long_time_format[i], LC_TIME); } } + } + /* Note we leave %5b etc. alone so user widths/flags are honored. */ if (strstr (long_time_format[0], "%b") || strstr (long_time_format[1], "%b")) From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 07:38:35 2011 Received: (at 10253) by debbugs.gnu.org; 11 Dec 2011 12:38:35 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZifq-0000HM-RH for submit@debbugs.gnu.org; Sun, 11 Dec 2011 07:38:35 -0500 Received: from caiajhbdcbhh.dreamhost.com ([208.97.132.177] helo=homiemail-a5.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZifj-0000GO-Dl for 10253@debbugs.gnu.org; Sun, 11 Dec 2011 07:38:32 -0500 Received: from homiemail-a5.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a5.g.dreamhost.com (Postfix) with ESMTP id 3BF5C704074; Sun, 11 Dec 2011 04:36:56 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:cc:subject :references:date:message-id:mime-version:content-type; q=dns; s= jidanni.org; b=pfwrDuEfd4OpIdHfqlfLuVciUogTlTEoAdI+35Y+H17eJVFS3 2bToVI+kktvswkOB9Dlm5lidqcgeewf/fGmkVKOgZ7gmHFjZopWGeYaAezkyKvrF HZy7TdmGmMv9/VQ+LOT5RIJUB37Os/WtB8Qe7PlB6NRzhZiogbDTR+1cSk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=+eWgJyyk3PEXsDGMvgMtgcUUCAk=; b=aaYrImRG0kH80 QPZmA4/6ptbeR1WdWM1DDMY9EdirfpIOehu8QzKHiukEm/4EFQ6C45hxhfbpziex iab6CuiEQxvQ3JEdcRwduoixUdm0cPfw+XZglJ4g+9rXItQFfbWaUJssQhpN+ldW maZOLwEYeOJ0UQuSmCmPfmkp508rHE= Received: from jidanni.org (218-163-23-126.dynamic.hinet.net [218.163.23.126]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a5.g.dreamhost.com (Postfix) with ESMTPSA id E84C170406E; Sun, 11 Dec 2011 04:36:55 -0800 (PST) From: jidanni@jidanni.org To: jim@meyering.net Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb References: <87k463bc4j.fsf@rho.meyering.net> Date: Sun, 11 Dec 2011 20:36:51 +0800 Message-ID: <87borfb7z0.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, eblake@redhat.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -3.4 (---) Thanks! From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 17:49:34 2011 Received: (at 10253) by debbugs.gnu.org; 11 Dec 2011 22:49:34 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZsD7-0006SZ-PI for submit@debbugs.gnu.org; Sun, 11 Dec 2011 17:49:34 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RZsD5-0006SS-Lf for 10253@debbugs.gnu.org; Sun, 11 Dec 2011 17:49:33 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 8D58439E800B; Sun, 11 Dec 2011 14:48:21 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nQ5uPGpdfR9w; Sun, 11 Dec 2011 14:48:21 -0800 (PST) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 108C239E8006; Sun, 11 Dec 2011 14:48:21 -0800 (PST) Message-ID: <4EE53334.8090705@cs.ucla.edu> Date: Sun, 11 Dec 2011 14:48:20 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb References: <87obvi8qc6.fsf@jidanni.org> <87liqlk0sv.fsf@rho.meyering.net> <4EE27DE6.60209@redhat.com> <87fwgse3nq.fsf@rho.meyering.net> <87k463bc4j.fsf@rho.meyering.net> In-Reply-To: <87k463bc4j.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, Eric Blake , jidanni@jidanni.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -2.9 (--) I like the change, thanks. A couple of nits: On 12/11/11 03:07, Jim Meyering wrote: > + fprintf (stderr, > + _(" - `+' followed by a date format string\n")); I suggest supplying an example and quoting "date" so that it's clearer that it's talking about the `date' command. Something like this, perhaps? _(" - +FORMAT (e.g., +%H:%M) for a `date'-style format\n") > + fprintf (stderr, " - `[posix-]%s'\n", *p++); I suggest removing the ` and ' since they are locale-dependent and aren't needed here (plus, that works better with the above suggestion....). > + fprintf (stderr, _("Valid arguments are:")); Isn't the usual style to use fputs when there's no directive in the format? There's one other example of this. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 05:13:08 2011 Received: (at 10253) by debbugs.gnu.org; 12 Dec 2011 10:13:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra2se-0004nE-3u for submit@debbugs.gnu.org; Mon, 12 Dec 2011 05:13:08 -0500 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra2sb-0004n5-Eg for 10253@debbugs.gnu.org; Mon, 12 Dec 2011 05:13:06 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 248E860092; Mon, 12 Dec 2011 11:11:53 +0100 (CET) From: Jim Meyering To: Paul Eggert Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb In-Reply-To: <4EE53334.8090705@cs.ucla.edu> (Paul Eggert's message of "Sun, 11 Dec 2011 14:48:20 -0800") References: <87obvi8qc6.fsf@jidanni.org> <87liqlk0sv.fsf@rho.meyering.net> <4EE27DE6.60209@redhat.com> <87fwgse3nq.fsf@rho.meyering.net> <87k463bc4j.fsf@rho.meyering.net> <4EE53334.8090705@cs.ucla.edu> Date: Mon, 12 Dec 2011 11:11:53 +0100 Message-ID: <87sjkqxfo6.fsf@rho.meyering.net> Lines: 162 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, Eric Blake , jidanni@jidanni.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -2.7 (--) Paul Eggert wrote: > I like the change, thanks. A couple of nits: > > On 12/11/11 03:07, Jim Meyering wrote: >> + fprintf (stderr, >> + _(" - `+' followed by a date format string\n")); > > I suggest supplying an example and quoting "date" so that it's clearer > that it's talking about the `date' command. Something like this, perhaps? > > _(" - +FORMAT (e.g., +%H:%M) for a `date'-style format\n") Thanks. That is better. >> + fprintf (stderr, " - `[posix-]%s'\n", *p++); > > I suggest removing the ` and ' since they are locale-dependent > and aren't needed here (plus, that works better with the above > suggestion....). Good point. Besides, I'd say that using quotes around syntax including the likes of `[posix-]...' is misleading in that it might encourage someone to use the []'s. >> + fprintf (stderr, _("Valid arguments are:")); > > Isn't the usual style to use fputs when there's no directive > in the format? There's one other example of this. Yes, that is my preference, too. Thanks for pointing it out. I copied both that format-less fprintf and the `' mark-up from argmatch.c. The fix there was easy: just use quote (...), since argmatch.c already includes quote.h, so I've just fixed that in gnulib. Here's a new version of the patch: [slightly risky for translators and fuzzy string matchers: now there are two very similar strings: "Valid arguments are:\n" (here in ls.c) "Valid arguments are:" (in gnulib's argmatch.c) It'd be easy rework argmatch.c to include the \n. ] Now it prints this: $ src/ls -l --time-style=x src/ls: invalid argument `x' for `time style' Valid arguments are: - [posix-]full-iso - [posix-]long-iso - [posix-]iso - [posix-]locale - +FORMAT (e.g., +%H:%M) for a `date'-style format Try `src/ls --help' for more information. >From 79a14f0481df2bd45a20f92ce4c156f42fdae660 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 11 Dec 2011 11:59:31 +0100 Subject: [PATCH] ls: give a more useful diagnostic for a bogus --time-style arg * src/ls.c (decode_switches): Replace our use of XARGMATCH with open-coded version so that we can give a better diagnostic. Reported by Dan Jacobson in http://bugs.gnu.org/10253 with suggestions from Eric Blake and Paul Eggert. --- src/ls.c | 72 +++++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/ls.c b/src/ls.c index 0d64bab..672237a 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2039,33 +2039,57 @@ decode_switches (int argc, char **argv) long_time_format[1] = p1; } else - switch (XARGMATCH ("time style", style, - time_style_args, - time_style_types)) - { - case full_iso_time_style: - long_time_format[0] = long_time_format[1] = - "%Y-%m-%d %H:%M:%S.%N %z"; - break; + { + ptrdiff_t res = argmatch (style, time_style_args, + (char const *) time_style_types, + sizeof (*time_style_types)); + if (res < 0) + { + /* This whole block used to be a simple use of XARGMATCH. + but that didn't print the "posix-"-prefixed variants or + the "+"-prefixed format string option upon failure. */ + argmatch_invalid ("time style", style, res); + + /* The following is a manual expansion of argmatch_valid, + but with the added "+ ..." description and the [posix-] + prefixes prepended. Note that this simplification works + only because all four existing time_style_types values + are distinct. */ + fputs (_("Valid arguments are:\n"), stderr); + char const *const *p = time_style_args; + while (*p) + fprintf (stderr, " - [posix-]%s\n", *p++); + fputs (_(" - +FORMAT (e.g., +%H:%M) for a `date'-style" + " format\n"), stderr); + usage (LS_FAILURE); + } + switch (res) + { + case full_iso_time_style: + long_time_format[0] = long_time_format[1] = + "%Y-%m-%d %H:%M:%S.%N %z"; + break; - case long_iso_time_style: - long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; - break; + case long_iso_time_style: + long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; + break; - case iso_time_style: - long_time_format[0] = "%Y-%m-%d "; - long_time_format[1] = "%m-%d %H:%M"; - break; + case iso_time_style: + long_time_format[0] = "%Y-%m-%d "; + long_time_format[1] = "%m-%d %H:%M"; + break; + + case locale_time_style: + if (hard_locale (LC_TIME)) + { + int i; + for (i = 0; i < 2; i++) + long_time_format[i] = + dcgettext (NULL, long_time_format[i], LC_TIME); + } + } + } - case locale_time_style: - if (hard_locale (LC_TIME)) - { - int i; - for (i = 0; i < 2; i++) - long_time_format[i] = - dcgettext (NULL, long_time_format[i], LC_TIME); - } - } /* Note we leave %5b etc. alone so user widths/flags are honored. */ if (strstr (long_time_format[0], "%b") || strstr (long_time_format[1], "%b")) -- 1.7.8.163.g9859a From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 06:22:08 2011 Received: (at 10253-done) by debbugs.gnu.org; 12 Dec 2011 11:22:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra3xQ-0006J6-Au for submit@debbugs.gnu.org; Mon, 12 Dec 2011 06:22:08 -0500 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra3xM-0006Ix-C5 for 10253-done@debbugs.gnu.org; Mon, 12 Dec 2011 06:22:06 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 5BFD96007E; Mon, 12 Dec 2011 12:20:51 +0100 (CET) From: Jim Meyering To: Paul Eggert Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb In-Reply-To: <87sjkqxfo6.fsf@rho.meyering.net> (Jim Meyering's message of "Mon, 12 Dec 2011 11:11:53 +0100") References: <87obvi8qc6.fsf@jidanni.org> <87liqlk0sv.fsf@rho.meyering.net> <4EE27DE6.60209@redhat.com> <87fwgse3nq.fsf@rho.meyering.net> <87k463bc4j.fsf@rho.meyering.net> <4EE53334.8090705@cs.ucla.edu> <87sjkqxfo6.fsf@rho.meyering.net> Date: Mon, 12 Dec 2011 12:20:51 +0100 Message-ID: <87hb16xch8.fsf@rho.meyering.net> Lines: 235 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 10253-done Cc: 10253-done@debbugs.gnu.org, Eric Blake , jidanni@jidanni.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -2.7 (--) Jim Meyering wrote: > Paul Eggert wrote: >> I like the change, thanks. A couple of nits: >> >> On 12/11/11 03:07, Jim Meyering wrote: >>> + fprintf (stderr, >>> + _(" - `+' followed by a date format string\n")); >> >> I suggest supplying an example and quoting "date" so that it's clearer >> that it's talking about the `date' command. Something like this, perhaps? >> >> _(" - +FORMAT (e.g., +%H:%M) for a `date'-style format\n") > > Thanks. That is better. > >>> + fprintf (stderr, " - `[posix-]%s'\n", *p++); >> >> I suggest removing the ` and ' since they are locale-dependent >> and aren't needed here (plus, that works better with the above >> suggestion....). > > Good point. Besides, I'd say that using quotes around syntax including > the likes of `[posix-]...' is misleading in that it might encourage > someone to use the []'s. > >>> + fprintf (stderr, _("Valid arguments are:")); >> >> Isn't the usual style to use fputs when there's no directive >> in the format? There's one other example of this. > > Yes, that is my preference, too. > Thanks for pointing it out. > > I copied both that format-less fprintf and the `' mark-up from argmatch.c. > The fix there was easy: just use quote (...), since argmatch.c already > includes quote.h, so I've just fixed that in gnulib. > > Here's a new version of the patch: > [slightly risky for translators and fuzzy string matchers: > now there are two very similar strings: > > "Valid arguments are:\n" (here in ls.c) > "Valid arguments are:" (in gnulib's argmatch.c) > > It'd be easy rework argmatch.c to include the \n. > ] > > Now it prints this: > > $ src/ls -l --time-style=x > src/ls: invalid argument `x' for `time style' > Valid arguments are: > - [posix-]full-iso > - [posix-]long-iso > - [posix-]iso > - [posix-]locale > - +FORMAT (e.g., +%H:%M) for a `date'-style format > Try `src/ls --help' for more information. I wrote a test, amended the preceding to include it and pushed this result: >From a3fee8b6afdbb70317d2124d5a3bb0d2887ab31b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 11 Dec 2011 11:59:31 +0100 Subject: [PATCH] ls: give a more useful diagnostic for a bogus --time-style arg * src/ls.c (decode_switches): Replace our use of XARGMATCH with open-coded version so that we can give a better diagnostic. * tests/ls/time-style-diag: New file. * tests/Makefile.am (TESTS): Add it. Reported by Dan Jacobson in http://bugs.gnu.org/10253 with suggestions from Eric Blake and Paul Eggert. --- gnulib | 2 +- src/ls.c | 72 ++++++++++++++++++++++++++++++--------------- tests/Makefile.am | 1 + tests/ls/time-style-diag | 39 +++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 25 deletions(-) create mode 100755 tests/ls/time-style-diag diff --git a/gnulib b/gnulib index a5f6df2..f5c2e2a 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit a5f6df2b1f3f0fdc73635de3ad285d21703dab18 +Subproject commit f5c2e2ac7d4ca2f6ba15e56a245f348899360a00 diff --git a/src/ls.c b/src/ls.c index 0d64bab..672237a 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2039,33 +2039,57 @@ decode_switches (int argc, char **argv) long_time_format[1] = p1; } else - switch (XARGMATCH ("time style", style, - time_style_args, - time_style_types)) - { - case full_iso_time_style: - long_time_format[0] = long_time_format[1] = - "%Y-%m-%d %H:%M:%S.%N %z"; - break; + { + ptrdiff_t res = argmatch (style, time_style_args, + (char const *) time_style_types, + sizeof (*time_style_types)); + if (res < 0) + { + /* This whole block used to be a simple use of XARGMATCH. + but that didn't print the "posix-"-prefixed variants or + the "+"-prefixed format string option upon failure. */ + argmatch_invalid ("time style", style, res); + + /* The following is a manual expansion of argmatch_valid, + but with the added "+ ..." description and the [posix-] + prefixes prepended. Note that this simplification works + only because all four existing time_style_types values + are distinct. */ + fputs (_("Valid arguments are:\n"), stderr); + char const *const *p = time_style_args; + while (*p) + fprintf (stderr, " - [posix-]%s\n", *p++); + fputs (_(" - +FORMAT (e.g., +%H:%M) for a `date'-style" + " format\n"), stderr); + usage (LS_FAILURE); + } + switch (res) + { + case full_iso_time_style: + long_time_format[0] = long_time_format[1] = + "%Y-%m-%d %H:%M:%S.%N %z"; + break; - case long_iso_time_style: - long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; - break; + case long_iso_time_style: + long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; + break; - case iso_time_style: - long_time_format[0] = "%Y-%m-%d "; - long_time_format[1] = "%m-%d %H:%M"; - break; + case iso_time_style: + long_time_format[0] = "%Y-%m-%d "; + long_time_format[1] = "%m-%d %H:%M"; + break; + + case locale_time_style: + if (hard_locale (LC_TIME)) + { + int i; + for (i = 0; i < 2; i++) + long_time_format[i] = + dcgettext (NULL, long_time_format[i], LC_TIME); + } + } + } - case locale_time_style: - if (hard_locale (LC_TIME)) - { - int i; - for (i = 0; i < 2; i++) - long_time_format[i] = - dcgettext (NULL, long_time_format[i], LC_TIME); - } - } /* Note we leave %5b etc. alone so user widths/flags are honored. */ if (strstr (long_time_format[0], "%b") || strstr (long_time_format[1], "%b")) diff --git a/tests/Makefile.am b/tests/Makefile.am index 48c33cb..23cb70f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -441,6 +441,7 @@ TESTS = \ ls/stat-free-symlinks \ ls/stat-vs-dirent \ ls/symlink-slash \ + ls/time-style-diag \ ls/x-option \ mkdir/p-1 \ mkdir/p-2 \ diff --git a/tests/ls/time-style-diag b/tests/ls/time-style-diag new file mode 100755 index 0000000..d756cfe --- /dev/null +++ b/tests/ls/time-style-diag @@ -0,0 +1,39 @@ +#!/bin/sh +# Ensure that an invalid --time-style=ARG is diagnosed the way we want. + +# Copyright (C) 2011 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +ls -l --time-style=XX > out 2> err +test $? = 2 || fail=1 + +cat <<\EOF > exp || fail=1 +ls: invalid argument `XX' for `time style' +Valid arguments are: + - [posix-]full-iso + - [posix-]long-iso + - [posix-]iso + - [posix-]locale + - +FORMAT (e.g., +%H:%M) for a `date'-style format +Try `ls --help' for more information. +EOF + +compare exp err || fail=1 +compare /dev/null out || fail=1 + +Exit $fail -- 1.7.8.163.g9859a From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 09:57:33 2011 Received: (at 10253) by debbugs.gnu.org; 12 Dec 2011 14:57:33 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra7Js-0003aq-Fq for submit@debbugs.gnu.org; Mon, 12 Dec 2011 09:57:33 -0500 Received: from caiajhbdccac.dreamhost.com ([208.97.132.202] helo=homiemail-a62.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra7Jp-0003ai-EZ for 10253@debbugs.gnu.org; Mon, 12 Dec 2011 09:57:30 -0500 Received: from homiemail-a62.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTP id 0F9D3634075; Mon, 12 Dec 2011 06:56:16 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:cc:subject :references:date:message-id:mime-version:content-type; q=dns; s= jidanni.org; b=ifKvmQ0qXcOCZNEG18fG4rDBB5YIWVVTlGVsZ/Yia2BnLrcnK XmLFdUtj8xz7mDVzYZqd6KX705Q70uy1yQ1s9cXWdfnisbvOtpftm7/9KCf7ioRf 9lm7Bi+mZ5Yf0GhAC3x0et+8Azsn7FeAOlxC8zbAidP7Tae6ceKoNH7o0Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=McjF55xAPkpg1bjfxKN/N3R4Rl8=; b=kOtsJejx0Z+zs KqyfEKl3FOyQVzwSxwihJGPByUqSAN2XzJ1JKWVSb1etsGn4E9ypwVtm7Ax+5rT9 xGFQUw3Cy7oukXQgWcrxAOpcp0oV1kPgD3ZQwKiNOk5V23DPqCpY2VEvycz+GKXP rH/HbI5ui8h7upr5WzkRNhgIi9FPyk= Received: from jidanni.org (218-163-21-160.dynamic.hinet.net [218.163.21.160]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTPSA id 8E9AD63406E; Mon, 12 Dec 2011 06:56:15 -0800 (PST) From: jidanni@jidanni.org To: jim@meyering.net Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb References: <87sjkqxfo6.fsf@rho.meyering.net> Date: Mon, 12 Dec 2011 22:56:12 +0800 Message-ID: <87y5uhhm9f.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, eggert@cs.ucla.edu, eblake@redhat.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -3.4 (---) >>>>> "JM" == Jim Meyering writes: JM> is misleading in that it might encourage someone to use the []'s. Like You Know Who :-), who also recommends you figure out a way to get rid of the JM> $ src/ls -l --time-style=x "src/" even in these e-mails/commits, as it is bad for the eye, even though it yes surely disappears in production. Having walked from the airport... I'll be dead soon http://www.youtube.com/watch?v=Tp8XcAKYsKo&list=PL6E40919035151385 From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 10:56:25 2011 Received: (at 10253) by debbugs.gnu.org; 12 Dec 2011 15:56:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra8Eq-0004yt-Ek for submit@debbugs.gnu.org; Mon, 12 Dec 2011 10:56:25 -0500 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra8Em-0004yj-EO for 10253@debbugs.gnu.org; Mon, 12 Dec 2011 10:56:21 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id B91C760092; Mon, 12 Dec 2011 16:55:06 +0100 (CET) From: Jim Meyering To: jidanni@jidanni.org Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb In-Reply-To: <87y5uhhm9f.fsf@jidanni.org> (jidanni@jidanni.org's message of "Mon, 12 Dec 2011 22:56:12 +0800") References: <87sjkqxfo6.fsf@rho.meyering.net> <87y5uhhm9f.fsf@jidanni.org> Date: Mon, 12 Dec 2011 16:55:06 +0100 Message-ID: <87r509wzs5.fsf@rho.meyering.net> Lines: 10 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, eggert@cs.ucla.edu, eblake@redhat.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -2.7 (--) jidanni@jidanni.org wrote: > JM> $ src/ls -l --time-style=x > "src/" even in these e-mails/commits, as it is bad for the eye, even though it > yes surely disappears in production. Actually, using the "src/" prefix (or some prefix, like "./") is important. Otherwise, I'm not testing what I've just built. Hence, including that prefix shows what I've done. Without it, the reader would wonder if I'd simply used whatever ls is in my path, which could easily represent a mistake. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 11:08:57 2011 Received: (at 10253) by debbugs.gnu.org; 12 Dec 2011 16:08:57 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra8Qy-0005HK-V9 for submit@debbugs.gnu.org; Mon, 12 Dec 2011 11:08:57 -0500 Received: from caiajhbdccah.dreamhost.com ([208.97.132.207] helo=homiemail-a1.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ra8Qw-0005HC-M5 for 10253@debbugs.gnu.org; Mon, 12 Dec 2011 11:08:55 -0500 Received: from homiemail-a1.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a1.g.dreamhost.com (Postfix) with ESMTP id B67A1348074; Mon, 12 Dec 2011 08:07:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:cc:subject :references:date:message-id:mime-version:content-type; q=dns; s= jidanni.org; b=lXLW82ST9XFEKtL8AsCSNiuf09cJZDe+w4ytEKsykoLGml5QU T44941JsKFhSEL2LC1dUC6Uf4FJcNvzUzQV1Nw9loP659KV4e8sS/vY3NPvMO5HX e3GbIlEsdbH/SPB0etCHV9eOljGyAJKL0SvJ5+dQz+PwiSvR7Gi+HblspE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=nyxWboT6QtOa6SlsuNdTH5mFLTk=; b=UtwqTIMEy87mZ cm1YP9bTGpECSSd03iQzx09ZRakWOfSDYz0fLg7Y1hKflTy7bMxb3it4w+bLBIXD hO75rf+7j924dPEo8DFHkmRpd10i+ple6YJogXF/SrYvndTVRz+cnx1jXwMlSZRJ IzbEId4J/6ROqK5I72epBW7fgXjHms= Received: from jidanni.org (218-163-21-160.dynamic.hinet.net [218.163.21.160]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a1.g.dreamhost.com (Postfix) with ESMTPSA id 31B1234806E; Mon, 12 Dec 2011 08:07:40 -0800 (PST) From: jidanni@jidanni.org To: jim@meyering.net Subject: Re: bug#10253: mention +FORMAT in ls time style reminder help blurb References: <87r509wzs5.fsf@rho.meyering.net> Date: Tue, 13 Dec 2011 00:07:37 +0800 Message-ID: <87sjkpzsc6.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 10253 Cc: 10253@debbugs.gnu.org, eggert@cs.ucla.edu, eblake@redhat.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -3.4 (---) >>>>> "JM" == Jim Meyering writes: JM> Hence, including that prefix shows what I've done. Without it, JM> the reader would wonder if I'd simply used whatever ls is in my path, JM> which could easily represent a mistake. Well OK then. From unknown Tue Aug 19 01:59:00 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, 10 Jan 2012 12:24:02 +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