From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 20 19:08:51 2011 Received: (at submit) by debbugs.gnu.org; 21 Jan 2011 00:08:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pg4Yd-0008FF-4B for submit@debbugs.gnu.org; Thu, 20 Jan 2011 19:08:51 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pg4Ya-0008F3-53 for submit@debbugs.gnu.org; Thu, 20 Jan 2011 19:08:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pg4gC-00087m-CW for submit@debbugs.gnu.org; Thu, 20 Jan 2011 19:16:41 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) 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.1 Received: from lists.gnu.org ([199.232.76.165]:47824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pg4gC-00087g-9f for submit@debbugs.gnu.org; Thu, 20 Jan 2011 19:16:40 -0500 Received: from [140.186.70.92] (port=47848 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pg4gB-0004Tv-4s for bug-coreutils@gnu.org; Thu, 20 Jan 2011 19:16:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pg4gA-000871-9W for bug-coreutils@gnu.org; Thu, 20 Jan 2011 19:16:39 -0500 Received: from caiajhbdcaib.dreamhost.com ([208.97.132.81]:48562 helo=homiemail-a7.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pg4gA-00086S-37 for bug-coreutils@gnu.org; Thu, 20 Jan 2011 19:16:38 -0500 Received: from homiemail-a7.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a7.g.dreamhost.com (Postfix) with ESMTP id 7F1AE25C064 for ; Thu, 20 Jan 2011 16:16:36 -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=hgg0xB1vaFaQZmZ5j7FeTu3SBdp9bUnRrwILLIxyXciNzZczKj3r6QZMREEr 4cMjgTtddL20GQaXEHdG4GBP8V98J5ibJ1mCeFbqL9oChhRgVvx6NuM4Nd4zHy+E qbce5mRTSTJsK5dv253Zm/o26juEUy7R0jyR4d4UPQnYdjM= 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=HwTWVonfM3K6tX3pNgTViqTXK9Q=; b=OhLR2ezd4SetWwFb FTdWnGeJ8a+ckvDjqZRmDvGAHA9/TjhyDxPCzwHPZ/+mlmgFDJXBpRNqDRi4N/x0 D2GUA0jBCbc0Er3t29VYg0lcZzAlFMVX6zZeJfghlHKP4n+dZeAzWhrNv+3exey5 m8OWBANZ2NDqkPPkXIUbVXpjfHY= Received: from jidanni.org (218-163-3-195.dynamic.hinet.net [218.163.3.195]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a7.g.dreamhost.com (Postfix) with ESMTPSA id D8A2A25C062 for ; Thu, 20 Jan 2011 16:16:35 -0800 (PST) From: jidanni@jidanni.org To: bug-coreutils@gnu.org Subject: sleep takes undocumented hex args Date: Fri, 21 Jan 2011 07:31:18 +0800 Message-ID: <8762tjcfuh.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, 2) 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 (-----) The documentation doesn't say that one can also use hex args: $ time /bin/sleep 0x10 real 0m16.007s However not octal args: $ time /bin/sleep 010 real 0m10.003s Maybe say how too. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 04:16:46 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 09:16:47 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgD6s-000396-An for submit@debbugs.gnu.org; Fri, 21 Jan 2011 04:16:46 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgD6q-00038t-6t for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 04:16:45 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id D1F186011F; Fri, 21 Jan 2011 10:24:36 +0100 (CET) From: Jim Meyering To: jidanni@jidanni.org Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <8762tjcfuh.fsf@jidanni.org> (jidanni@jidanni.org's message of "Fri, 21 Jan 2011 07:31:18 +0800") References: <8762tjcfuh.fsf@jidanni.org> Date: Fri, 21 Jan 2011 10:24:36 +0100 Message-ID: <878vyek3sb.fsf@meyering.net> Lines: 134 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 7877 Cc: 7877@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: -5.7 (-----) jidanni@jidanni.org wrote: > The documentation doesn't say that one can also use hex args: > $ time /bin/sleep 0x10 > real 0m16.007s > However not octal args: > $ time /bin/sleep 010 > real 0m10.003s Interesting. Thanks for the report. That's an artifact of GNU sleep using strtod, which means "inf" and "INFINITY" are also accepted: $ timeout 1 sleep inf [Exit 124] My first reflex was to make sleep reject args like 0x... and inf. However, that would mean duplicating the parsing that strtod does, in order to detect-and-skip leading isspace and/or "+". No one likes duplication, but in this case it's not so bad, and seems better than documenting the "extension", so I wrote the patch: >From 2bf8d9172cf653b31c202f327b3cc6240acec867 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 21 Jan 2011 09:56:15 +0100 Subject: [PATCH] sleep: do not accept "inf" or hexadecimal numbers like 0x10 * src/sleep.c (strtod_pre_filter): New function. (main): Use it. * tests/misc/sleep-hex: New file. Test for the above change. * tests/Makefile.am (TESTS): Add it. Reported by Dan Jacobson in http://debbugs.gnu.org/7877 --- src/sleep.c | 20 +++++++++++++++++++- tests/Makefile.am | 1 + tests/misc/sleep-hex | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletions(-) create mode 100755 tests/misc/sleep-hex diff --git a/src/sleep.c b/src/sleep.c index d32daa4..36ee271 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -96,6 +96,23 @@ apply_suffix (double *x, char suffix_char) return true; } +/* strtod accepts strings like "INF" and "infinity" as well as + hexadecimal representations, but we'd rather not extend sleep + to accept such inputs, so reject them here. Return false for + such otherwise-valid inputs to strtod and true otherwise. */ +static bool +strtod_pre_filter (char const *s) +{ + char const *p = s; + while (isspace (*p)) + ++p; + if (*p == '+') + ++p; + if (*p == '0' && (p[1] == 'x' || p[1] == 'X')) + return false; + return ISDIGIT (*p) || *p == '.'; +} + int main (int argc, char **argv) { @@ -126,7 +143,8 @@ main (int argc, char **argv) { double s; const char *p; - if (! xstrtod (argv[i], &p, &s, c_strtod) + if (! strtod_pre_filter (argv[i]) + || ! xstrtod (argv[i], &p, &s, c_strtod) /* Nonnegative interval. */ || ! (0 <= s) /* No extra chars after the number and an optional s,m,h,d char. */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 1e4e300..3d08a73 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -225,6 +225,7 @@ TESTS = \ misc/shred-passes \ misc/shred-remove \ misc/shuf \ + misc/sleep-hex \ misc/sort \ misc/sort-benchmark-random \ misc/sort-compress \ diff --git a/tests/misc/sleep-hex b/tests/misc/sleep-hex new file mode 100755 index 0000000..a60a009 --- /dev/null +++ b/tests/misc/sleep-hex @@ -0,0 +1,37 @@ +#!/bin/sh +# Ensure that sleep rejects "inf", 0x10 etc. + +# 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_ sleep + +sleep 0 || fail=1 +sleep +0 || fail=1 +sleep +.001 || fail=1 +sleep 0.001 || fail=1 +sleep 1e-4 || fail=1 +sleep +1E-4 || fail=1 + +# The following were all accepted by coreutils-8.9 and earlier. +# Now, such arguments are rejected. +sleep +0x10 && fail=1 +sleep 0x10 && fail=1 +sleep INF && fail=1 +sleep +INF && fail=1 +sleep infinity && fail=1 + +Exit $fail -- 1.7.3.5 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 05:23:20 2011 Received: (at submit) by debbugs.gnu.org; 21 Jan 2011 10:23:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgE9H-0004bi-U1 for submit@debbugs.gnu.org; Fri, 21 Jan 2011 05:23:20 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgE9F-0004bY-Oc for submit@debbugs.gnu.org; Fri, 21 Jan 2011 05:23:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgEGo-0005SN-8f for submit@debbugs.gnu.org; Fri, 21 Jan 2011 05:31:11 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:41128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgEGo-0005SI-5n for submit@debbugs.gnu.org; Fri, 21 Jan 2011 05:31:06 -0500 Received: from [140.186.70.92] (port=45803 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgEGl-000080-KG for bug-coreutils@gnu.org; Fri, 21 Jan 2011 05:31:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgEGj-0005Qi-Br for bug-coreutils@gnu.org; Fri, 21 Jan 2011 05:31:03 -0500 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]:11550) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PgEGj-0005Pw-6E for bug-coreutils@gnu.org; Fri, 21 Jan 2011 05:31:01 -0500 Received: (qmail 53402 invoked from network); 21 Jan 2011 10:30:59 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 21 Jan 2011 10:30:59 -0000 Message-ID: <4D39601B.7070300@draigBrady.com> Date: Fri, 21 Jan 2011 10:29:47 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: Re: bug#7877: sleep takes undocumented hex args References: <8762tjcfuh.fsf@jidanni.org> <878vyek3sb.fsf@meyering.net> In-Reply-To: <878vyek3sb.fsf@meyering.net> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: FreeBSD 4.6-4.9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -4.7 (----) 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: -4.7 (----) On 21/01/11 09:24, Jim Meyering wrote: > + return false; > + return ISDIGIT (*p) || *p == '.'; > +} looks good. Perhaps rename to c_strtod_pre_filter() as I initially wondered why you hardcoded '.' cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 05:29:03 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 10:29:03 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgEEo-0004jE-Se for submit@debbugs.gnu.org; Fri, 21 Jan 2011 05:29:03 -0500 Received: from m0019.fra.mmp.de.bt.com ([62.180.227.30] helo=ms03.m0019.fra.mmp.de.bt.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgEEm-0004ik-Fh for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 05:29:01 -0500 Received: from senmx11-mx ([62.134.46.9] [62.134.46.9]) by ms03.m0020.fra.mmp.de.bt.com with ESMTP id BT-MMP-3086999; Fri, 21 Jan 2011 11:35:12 +0100 Received: from MCHP064A.global-ad.net (unknown [172.29.37.63]) by senmx11-mx (Server) with ESMTP id 56E561EB82B4; Fri, 21 Jan 2011 11:35:12 +0100 (CET) Received: from MCHP058A.global-ad.net ([172.29.37.57]) by MCHP064A.global-ad.net ([172.29.37.63]) with mapi; Fri, 21 Jan 2011 11:35:12 +0100 From: "Voelker, Bernhard" To: Jim Meyering , "jidanni@jidanni.org" Date: Fri, 21 Jan 2011 11:35:12 +0100 Subject: RE: bug#7877: sleep takes undocumented hex args Thread-Topic: bug#7877: sleep takes undocumented hex args Thread-Index: Acu5UaIbp8yuJmgmRamrazpPuF//vwABQv/Q Message-ID: <7856072A9D04C24B82DFE2B1112FE38A0508F8E6C7@MCHP058A.global-ad.net> References: <8762tjcfuh.fsf@jidanni.org> <878vyek3sb.fsf@meyering.net> In-Reply-To: <878vyek3sb.fsf@meyering.net> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE, en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Score: -2.5 (--) X-Debbugs-Envelope-To: 7877 Cc: "7877@debbugs.gnu.org" <7877@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.5 (--) Jim Meyering wrote: > That's an artifact of GNU sleep using strtod, which means "inf" and > "INFINITY" are also accepted: >=20 > $ timeout 1 sleep inf > [Exit 124] what's wrong with `sleep inf`? Have a nice day, Berny= From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 06:04:23 2011 Received: (at submit) by debbugs.gnu.org; 21 Jan 2011 11:04: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 1PgEn1-0005U0-Ld for submit@debbugs.gnu.org; Fri, 21 Jan 2011 06:04:23 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgEmy-0005Tn-Kd for submit@debbugs.gnu.org; Fri, 21 Jan 2011 06:04:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgEub-0007TE-P2 for submit@debbugs.gnu.org; Fri, 21 Jan 2011 06:12:14 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:50563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgEub-0007TA-NC for submit@debbugs.gnu.org; Fri, 21 Jan 2011 06:12:13 -0500 Received: from [140.186.70.92] (port=47124 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgEua-0005bh-92 for bug-coreutils@gnu.org; Fri, 21 Jan 2011 06:12:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgEuY-0007S3-9q for bug-coreutils@gnu.org; Fri, 21 Jan 2011 06:12:12 -0500 Received: from mx.meyering.net ([82.230.74.64]:51969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgEuY-0007Rk-3f for bug-coreutils@gnu.org; Fri, 21 Jan 2011 06:12:10 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 5E3D660242; Fri, 21 Jan 2011 12:12:08 +0100 (CET) From: Jim Meyering To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <4D39601B.7070300@draigBrady.com> (=?iso-8859-1?Q?=22P=E1drai?= =?iso-8859-1?Q?g?= Brady"'s message of "Fri, 21 Jan 2011 10:29:47 +0000") References: <8762tjcfuh.fsf@jidanni.org> <878vyek3sb.fsf@meyering.net> <4D39601B.7070300@draigBrady.com> Date: Fri, 21 Jan 2011 12:12:08 +0100 Message-ID: <87lj2eik8n.fsf@meyering.net> Lines: 10 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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, 2) X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: submit Cc: bug-coreutils@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: -5.7 (-----) P=E1draig Brady wrote: > On 21/01/11 09:24, Jim Meyering wrote: >> + return false; >> + return ISDIGIT (*p) || *p =3D=3D '.'; >> +} > > looks good. Perhaps rename to c_strtod_pre_filter() > as I initially wondered why you hardcoded '.' Good idea. Done. Thanks for the quick review. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 06:30:08 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 11:30: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 1PgFBv-000650-8b for submit@debbugs.gnu.org; Fri, 21 Jan 2011 06:30:07 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgFBq-00064D-V3 for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 06:30:04 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 62BD8601C0; Fri, 21 Jan 2011 12:37:55 +0100 (CET) From: Jim Meyering To: "Voelker\, Bernhard" Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <7856072A9D04C24B82DFE2B1112FE38A0508F8E6C7@MCHP058A.global-ad.net> (Bernhard Voelker's message of "Fri, 21 Jan 2011 11:35:12 +0100") References: <8762tjcfuh.fsf@jidanni.org> <878vyek3sb.fsf@meyering.net> <7856072A9D04C24B82DFE2B1112FE38A0508F8E6C7@MCHP058A.global-ad.net> Date: Fri, 21 Jan 2011 12:37:55 +0100 Message-ID: <87fwsmij1o.fsf@meyering.net> Lines: 27 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 7877 Cc: "7877@debbugs.gnu.org" <7877@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: -5.7 (-----) Voelker, Bernhard wrote: > Jim Meyering wrote: >> That's an artifact of GNU sleep using strtod, which means "inf" and >> "INFINITY" are also accepted: >> >> $ timeout 1 sleep inf >> [Exit 124] > > what's wrong with `sleep inf`? Hi Volker, There's nothing terribly _wrong_ with it, but I am inclined not to add the feature for the same reason I don't want to simply document that sleep accepts 0x10 and treats it like "16": those are incidental implementation details. Once we document such a thing, we then commit to ensuring it works everywhere, and in a sense encourage people to use the "feature". However, officially supporting "inf" doesn't gain much, yet imposes a portability burden: does every strtod implementation convert "inf" to something reasonable? I doubt it. If you want to sleep for a long time, you can use sleep $(echo 2^32|bc) or sleep 999999d. If you're worried that 2700 years is not enough ;-), use this: while :; do sleep 99d || break; done From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 07:40:27 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 12:40:27 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgGHz-0008Ly-7L for submit@debbugs.gnu.org; Fri, 21 Jan 2011 07:40:27 -0500 Received: from caiajhbdccac.dreamhost.com ([208.97.132.202] helo=homiemail-a3.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgGHw-0008Lm-CX for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 07:40:25 -0500 Received: from homiemail-a3.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a3.g.dreamhost.com (Postfix) with ESMTP id 93A93284076; Fri, 21 Jan 2011 04:48:17 -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=QdDMB2uKoM17Pe7pnU8wB3Ss0hcOuJy7s0GGNoGENJkv4kMqg BVMrbsUP6PdgnctfbatpxV5ADubX1VWJtMGvD8ypKwMxn5YHfSn3RszO6tvUvi6x u2Zq4+oL3759gFf26alQIx+h0Fch6OWGrmN11RgS3t0HPeQbAZINw38Xm0= 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=qiuFPd46NbKAMMy/FgTGWkyrAnQ=; b=H4udzdLZP5cox YeAPnF/kFeC/OJ8qGUXSp4xFXdtiyBtpR+CUuXSz1pSeIPo9uKD05A5HiCP05Uuy /3Gjc75LZHLlgpahKOHLTyg4aH8xDMdDo9EAhTjGhq2We6qa4tqlvMczTVlICqNp La6lRQbee0+ZDpYCnQ6ssQdVZMi27U= Received: from jidanni.org (218-163-6-126.dynamic.hinet.net [218.163.6.126]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a3.g.dreamhost.com (Postfix) with ESMTPSA id 39DDF284071; Fri, 21 Jan 2011 04:48:17 -0800 (PST) From: jidanni@jidanni.org To: jim@meyering.net Subject: Re: bug#7877: sleep takes undocumented hex args References: <87fwsmij1o.fsf@meyering.net> Date: Fri, 21 Jan 2011 20:48:14 +0800 Message-ID: <878vyebey9.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, bernhard.voelker@siemens-enterprise.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 (---) You see I was trying to make very special arguments to sleep so that I can make sure to kill the one I want pkill -u jidanni -fx sleep\ 000022 It is not clear if that will still work. Maybe the man/info page should say a regexp that matches all valid args. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 07:55:51 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 12:55:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgGWs-0000El-Vb for submit@debbugs.gnu.org; Fri, 21 Jan 2011 07:55:51 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgGWq-0000EV-8X for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 07:55:49 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 2D30F6031E; Fri, 21 Jan 2011 14:03:41 +0100 (CET) From: Jim Meyering To: jidanni@jidanni.org Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <878vyebey9.fsf@jidanni.org> (jidanni@jidanni.org's message of "Fri, 21 Jan 2011 20:48:14 +0800") References: <87fwsmij1o.fsf@meyering.net> <878vyebey9.fsf@jidanni.org> Date: Fri, 21 Jan 2011 14:03:41 +0100 Message-ID: <87aaiuif2q.fsf@meyering.net> Lines: 17 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, bernhard.voelker@siemens-enterprise.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: -5.7 (-----) jidanni@jidanni.org wrote: > You see I was trying to make very special arguments to sleep so that I > can make sure to kill the one I want > pkill -u jidanni -fx sleep\ 000022 > It is not clear if that will still work. With today's change using "sleep 000022" will still act just like "sleep 22". I could not change that (and would not want to!) without breaking with years of tradition. > Maybe the man/info page should > say a regexp that matches all valid args. It already describes the format pretty well, mentioning "floating point" and the four suffixes. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 07:57:50 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 12:57:50 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgGYn-0000Hc-P4 for submit@debbugs.gnu.org; Fri, 21 Jan 2011 07:57:50 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgGYl-0000HR-GM for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 07:57:47 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 3AC05601C0; Fri, 21 Jan 2011 14:05:41 +0100 (CET) From: Jim Meyering To: jidanni@jidanni.org Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <878vyebey9.fsf@jidanni.org> (jidanni@jidanni.org's message of "Fri, 21 Jan 2011 20:48:14 +0800") References: <87fwsmij1o.fsf@meyering.net> <878vyebey9.fsf@jidanni.org> Date: Fri, 21 Jan 2011 14:05:41 +0100 Message-ID: <87zkquh0ey.fsf@meyering.net> Lines: 35 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, bernhard.voelker@siemens-enterprise.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: -5.7 (-----) jidanni@jidanni.org wrote: > You see I was trying to make very special arguments to sleep so that I > can make sure to kill the one I want > pkill -u jidanni -fx sleep\ 000022 > It is not clear if that will still work. Maybe the man/info page should > say a regexp that matches all valid args. BTW, reading the manual I spotted a small problem. Here's the fix: >From 2e8de846204e36a5876d00605caf7457a79fb552 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 21 Jan 2011 14:02:27 +0100 Subject: [PATCH] doc: fix wording in warning about potential conflict with built-in * doc/coreutils.texi (mayConflictWithShellBuiltIn): Fix wording. --- doc/coreutils.texi | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 8a1b3b6..746ab8c 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -624,7 +624,7 @@ Common options @macro mayConflictWithShellBuiltIn{cmd} @cindex conflicts with shell built-ins @cindex built-in shell commands, conflicts with -Due to shell aliases and built-in @command{\cmd\} command, using an +Due to shell aliases and built-in @command{\cmd\} functions, using an unadorned @command{\cmd\} interactively or in a script may get you different functionality than that described here. Invoke it via @command{env} (i.e., @code{env \cmd\ @dots{}}) to avoid interference -- 1.7.3.5 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 08:01:57 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 13:01: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 1PgGcn-0000Nr-4t for submit@debbugs.gnu.org; Fri, 21 Jan 2011 08:01:57 -0500 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1PgGcl-0000Ne-EE for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 08:01:56 -0500 Received: (qmail 88685 invoked from network); 21 Jan 2011 13:09:48 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 21 Jan 2011 13:09:48 -0000 Message-ID: <4D398554.6060000@draigBrady.com> Date: Fri, 21 Jan 2011 13:08:36 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: jidanni@jidanni.org Subject: Re: bug#7877: sleep takes undocumented hex args References: <87fwsmij1o.fsf@meyering.net> <878vyebey9.fsf@jidanni.org> In-Reply-To: <878vyebey9.fsf@jidanni.org> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 7877 Cc: 7877@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 (--) On 21/01/11 12:48, jidanni@jidanni.org wrote: > You see I was trying to make very special arguments to sleep so that I > can make sure to kill the one I want > pkill -u jidanni -fx sleep\ 000022 > It is not clear if that will still work. Maybe the man/info page should > say a regexp that matches all valid args. sleeps args are cumulative, so you can: sleep 0 0 0 0 22 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 09:43:53 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 14:43:53 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgIDQ-0002ZU-P7 for submit@debbugs.gnu.org; Fri, 21 Jan 2011 09:43:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgIDO-0002ZF-KF for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 09:43:51 -0500 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.13.8/8.13.8) with ESMTP id p0LEpiTX008101 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Jan 2011 09:51:44 -0500 Received: from [10.3.113.109] (ovpn-113-109.phx2.redhat.com [10.3.113.109]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0LEphhB030572; Fri, 21 Jan 2011 09:51:43 -0500 Message-ID: <4D399D7E.1060103@redhat.com> Date: Fri, 21 Jan 2011 07:51:42 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#7877: sleep takes undocumented hex args References: <87fwsmij1o.fsf@meyering.net> <878vyebey9.fsf@jidanni.org> <87aaiuif2q.fsf@meyering.net> In-Reply-To: <87aaiuif2q.fsf@meyering.net> X-Enigmail-Version: 1.1.2 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigC69D5A9759FB2A1A30832BC2" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -10.2 (----------) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, bernhard.voelker@siemens-enterprise.com, 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.2 (----------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC69D5A9759FB2A1A30832BC2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/21/2011 06:03 AM, Jim Meyering wrote: > jidanni@jidanni.org wrote: >> You see I was trying to make very special arguments to sleep so that I= >> can make sure to kill the one I want >> pkill -u jidanni -fx sleep\ 000022 >> It is not clear if that will still work. >=20 > With today's change using "sleep 000022" will > still act just like "sleep 22". >=20 > I could not change that (and would not want to!) > without breaking with years of tradition. >=20 >> Maybe the man/info page should >> say a regexp that matches all valid args. >=20 > It already describes the format pretty well, > mentioning "floating point" and the four suffixes. Floating point literals include hex-floats, such as 0x1p1. Does today's added pre-filtering to reject 0x1 accidentally also reject hex-float literals? (It's a bit of a shame that when hex-floats were added that strtod() was altered to accept hex-float literals but as a side effect it also started accepting hexadecimal values without the p[+-]?[0-9]+ exponent suffix). --=20 Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enigC69D5A9759FB2A1A30832BC2 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 Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJNOZ1+AAoJEKeha0olJ0NqzQkH/RTa1FYvjo+3fWSRDZHermzz UfZgptNIwbat/uYN/5i2P9ZAFllECxSCW1LgVeZTvKc82ytg1g8wqUvZORcMbWwR MBd+IF5sHa2GZae14e4k77S9H/9Qrd6AYtxulsDTgBalJQO1DfE+t7AYXGjdOdtT K/B7gnttpkVQbrj124u4ad4MGhj4XYt6FKY1Mky4vKdxQ+NATGNRJ8tvjVtniu3O nXdY+Aij/zgj/ia1JrLrXDHBPsXN/x/2m5dcOVdKPSYRCsSlrlwFQMB/3+YftUeY ehxY2CzBvHtfVQXBlDg88MNia4T6EN3bSGB5sQxaWVyDvBo/lE7y1DFtgRMi92Q= =DUge -----END PGP SIGNATURE----- --------------enigC69D5A9759FB2A1A30832BC2-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 09:50:03 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 14:50:03 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgIJO-0002i9-LV for submit@debbugs.gnu.org; Fri, 21 Jan 2011 09:50:02 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgIJE-0002he-C7 for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 09:50:00 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 0B1C8601C0; Fri, 21 Jan 2011 15:57:44 +0100 (CET) From: Jim Meyering To: Eric Blake Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <4D399D7E.1060103@redhat.com> (Eric Blake's message of "Fri, 21 Jan 2011 07:51:42 -0700") References: <87fwsmij1o.fsf@meyering.net> <878vyebey9.fsf@jidanni.org> <87aaiuif2q.fsf@meyering.net> <4D399D7E.1060103@redhat.com> Date: Fri, 21 Jan 2011 15:57:44 +0100 Message-ID: <87aaiugv87.fsf@meyering.net> Lines: 32 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, bernhard.voelker@siemens-enterprise.com, 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: -5.7 (-----) Eric Blake wrote: > On 01/21/2011 06:03 AM, Jim Meyering wrote: >> jidanni@jidanni.org wrote: >>> You see I was trying to make very special arguments to sleep so that I >>> can make sure to kill the one I want >>> pkill -u jidanni -fx sleep\ 000022 >>> It is not clear if that will still work. >> >> With today's change using "sleep 000022" will >> still act just like "sleep 22". >> >> I could not change that (and would not want to!) >> without breaking with years of tradition. >> >>> Maybe the man/info page should >>> say a regexp that matches all valid args. >> >> It already describes the format pretty well, >> mentioning "floating point" and the four suffixes. > > Floating point literals include hex-floats, such as 0x1p1. Does today's > added pre-filtering to reject 0x1 accidentally also reject hex-float > literals? (It's a bit of a shame that when hex-floats were added that > strtod() was altered to accept hex-float literals but as a side effect > it also started accepting hexadecimal values without the p[+-]?[0-9]+ > exponent suffix). I see no significant utility in accepting hex floats. Do you? If you're concerned about errors in conversion or the efficiency of the conversion process, then you probably don't want to use the sleep command in the first place. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 09:51:39 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 14:51:39 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgIKw-0002kP-Vf for submit@debbugs.gnu.org; Fri, 21 Jan 2011 09:51:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgIKt-0002kC-TM for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 09:51:36 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0LExTBA008137 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Jan 2011 09:59:29 -0500 Received: from [10.3.113.109] (ovpn-113-109.phx2.redhat.com [10.3.113.109]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0LExS4Z026632; Fri, 21 Jan 2011 09:59:28 -0500 Message-ID: <4D399F50.60601@redhat.com> Date: Fri, 21 Jan 2011 07:59:28 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#7877: sleep takes undocumented hex args References: <87fwsmij1o.fsf@meyering.net> <878vyebey9.fsf@jidanni.org> <87aaiuif2q.fsf@meyering.net> <4D399D7E.1060103@redhat.com> <87aaiugv87.fsf@meyering.net> In-Reply-To: <87aaiugv87.fsf@meyering.net> X-Enigmail-Version: 1.1.2 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1A8612F4F7C62EE8105E80BC" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -10.2 (----------) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, bernhard.voelker@siemens-enterprise.com, 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.2 (----------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1A8612F4F7C62EE8105E80BC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/21/2011 07:57 AM, Jim Meyering wrote: >> Floating point literals include hex-floats, such as 0x1p1. Does today= 's >> added pre-filtering to reject 0x1 accidentally also reject hex-float >> literals? (It's a bit of a shame that when hex-floats were added that= >> strtod() was altered to accept hex-float literals but as a side effect= >> it also started accepting hexadecimal values without the p[+-]?[0-9]+ >> exponent suffix). >=20 > I see no significant utility in accepting hex floats. Do you? No, and rejecting them is fine with me, although our documentation should be tweaked to be clear that we don't accept _all_ floating point literals, but just those with optional e[+-]?[0-9]+ suffix. --=20 Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enig1A8612F4F7C62EE8105E80BC 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 Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJNOZ9QAAoJEKeha0olJ0NqXZIIAIsGRcC+oU7kn4X+kqcmML64 8S6nd2C+NC49/0fy2ZEKnz6mH7VaZYzXSACmYrD3R+KoCg8fE9l774TnYI8zr0Tj cIFfTlnuNZub7i/F0KELH7BJTJLKGFmTeGNG21HZUxoBFassefGzZmd4a+nWxB+f XgTadqW1TqN/mc17LPDz7JROaxbYvBgv1uvAyqpXrnCLSOD4fa4eaBdhxvVfb+eV nkqvijGmdD/UIRPPh/UlyrKuUaTQTnjKPdg+9+nAZrK8LpBfJ8pqngzVLgXIHYP/ 8iC6yw566UcCNH4cfXL8t54lZKYycoU8Om9qARa4IgBOnydZt0f+at8u9N3M/oo= =eVkk -----END PGP SIGNATURE----- --------------enig1A8612F4F7C62EE8105E80BC-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 13:59:48 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 18:59:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgMD5-0000XN-Bt for submit@debbugs.gnu.org; Fri, 21 Jan 2011 13:59:47 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgMD1-0000X8-Kq for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 13:59:45 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 7DEA339E80F2; Fri, 21 Jan 2011 11:07:37 -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 Ug9Uis39nBJb; Fri, 21 Jan 2011 11:07:36 -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 18FD739E80E0; Fri, 21 Jan 2011 11:07:36 -0800 (PST) Message-ID: <4D39D977.4030904@cs.ucla.edu> Date: Fri, 21 Jan 2011 11:07:35 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#7877: sleep takes undocumented hex args References: <8762tjcfuh.fsf@jidanni.org> <878vyek3sb.fsf@meyering.net> In-Reply-To: <878vyek3sb.fsf@meyering.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 7877 Cc: 7877@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.9 (--) On 01/21/2011 01:24 AM, Jim Meyering wrote: > My first reflex was to make sleep reject args like 0x... and inf. My reflex was just the opposite: why reject a notation that might be useful? Several other programs (printf, seq, sort, tail, plus many other GNU programs) also use strtod or strtold. If 'sleep' is changed to reject hexadecimal and infinity, shouldn't they be changed too, for consistency? I expect it's better to leave these programs alone. Not only is this simpler, and a tiny bit cheaper at runtime, it's slightly less likely to break existing usage. Anyway, whatever we do, we should document it better. To start the ball rolling on that, I pushed the following change, which documents the existing behavior. We can change this if we change the behavior. >From df79069b2cfb8435e8b33693c9e03e8689b2659b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 21 Jan 2011 10:59:32 -0800 Subject: [PATCH] manual: document floating point better * doc/coreutils.texi (Floating point): New section. (od invocation, tail invocation, sort invocation, printf invocation): (sleep invocation, seq invocation): Refer and defer to it. See . --- doc/coreutils.texi | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 39 insertions(+), 13 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 8a1b3b6..926171c 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -217,6 +217,7 @@ Common Options * Exit status:: Indicating program success or failure * Backup options:: Backup options * Block size:: Block size +* Floating point:: Floating point number representation * Signal specifications:: Specifying signals * Disambiguating names and IDs:: chgrp and chown owner and group syntax * Random sources:: Sources of random data @@ -729,6 +730,7 @@ name. * Exit status:: Indicating program success or failure. * Backup options:: -b -S, in some programs. * Block size:: BLOCK_SIZE and --block-size, in some programs. +* Floating point:: Floating point number representation. * Signal specifications:: Specifying signals using the --signal option. * Disambiguating names and IDs:: chgrp and chown owner and group syntax * Random sources:: --random-source, in some programs. @@ -1011,6 +1013,34 @@ set. The @option{-h} or @option{--human-readable} option is equivalent to @option{--block-size=human-readable}. The @option{--si} option is equivalent to @option{--block-size=si}. +@node Floating point +@section Floating point numbers +@cindex floating point +@cindex IEEE floating point + +Commands that accept or produce floating point numbers employ the +floating point representation of the underlying system, and suffer +from rounding error, overflow, and similar floating-point issues. +Almost all modern systems use IEEE-754 floating point, and it is +typically portable to assume IEEE-754 behavior these days. IEEE-754 +has positive and negative infinity, distinguishes positive from +negative zero, and uses special values called NaNs to represent +invalid computations such as dividing zero by itself. For more +information, please see David Goldberg's paper +@uref{http://@/www.validlab.com/@/goldberg/@/paper.pdf, What Every +Computer Scientist Should Know About Floating-Point Arithmetic}. + +@vindex LC_NUMERIC +Commands that accept floating point numbers as options, operands or +input use the standard C functions @code{strtod} and @code{strtold} to +convert from text to floating point numbers. These floating point +numbers therefore can use scientific notation like @code{1.0e-34} and +@code{-10e100}. Modern C implementations also accept hexadecimal +floating point numbers such as @code{-0x.ep-3}, which stands for +@minus{}14/16 times @math{2^-3}, which equals @minus{}0.109375. The +@env{LC_NUMERIC} locale determines the decimal-point character. +@xref{Parsing of Floats,,, libc, The GNU C Library Reference Manual}. + @node Signal specifications @section Signal specifications @cindex signals, specifying @@ -1880,7 +1910,7 @@ named character, ignoring high-order bit @item d signed decimal @item f -floating point +floating point (@pxref{Floating point}) @item o octal @item u @@ -2820,8 +2850,7 @@ During one iteration, every specified file is checked to see if it has changed size. Historical implementations of @command{tail} have required that @var{number} be an integer. However, GNU @command{tail} accepts -an arbitrary floating point number (using a period before any -fractional digits). +an arbitrary floating point number. @xref{Floating point}. When @command{tail} uses inotify, this polling-related option is ignored. @itemx --pid=@var{pid} @@ -3883,11 +3912,8 @@ the final result, after the throwing away.)) @opindex --sort @cindex general numeric sort @vindex LC_NUMERIC -Sort numerically, using the standard C function @code{strtold} to convert -a prefix of each line to a long double-precision floating point number. -This allows floating point numbers to be specified in scientific notation, -like @code{1.0e-34} and @code{10e100}. -The @env{LC_NUMERIC} locale determines the decimal-point character. +Sort numerically, converting a prefix of each line to a long +double-precision floating point number. @xref{Floating point}. Do not report overflow, underflow, or conversion errors. Use the following collating sequence: @@ -11209,6 +11235,7 @@ digits, but is printed according to the @env{LC_NUMERIC} category of the current locale. For example, in a locale whose radix character is a comma, the command @samp{printf %g 3.14} outputs @samp{3,14} whereas the command @samp{printf %g 3,14} is an error. +@xref{Floating point}. @kindex \@var{ooo} @kindex \x@var{hh} @@ -15664,8 +15691,7 @@ days Historical implementations of @command{sleep} have required that @var{number} be an integer, and only accepted a single argument without a suffix. However, GNU @command{sleep} accepts -arbitrary floating point numbers (using a period before any fractional -digits). +arbitrary floating point numbers. @xref{Floating point}. The only options are @option{--help} and @option{--version}. @xref{Common options}. @@ -15765,8 +15791,7 @@ When @var{increment} is not specified, it defaults to @samp{1}, even when @var{first} is larger than @var{last}. @var{first} also defaults to @samp{1}. So @code{seq 1} prints @samp{1}, but @code{seq 0} and @code{seq 10 5} produce no output. -Floating-point numbers -may be specified (using a period before any fractional digits). +Floating-point numbers may be specified. @xref{Floating point}. The program accepts the following options. Also see @ref{Common options}. Options must precede operands. @@ -15843,7 +15868,8 @@ of @code{%x}. On most systems, seq can produce whole-number output for values up to at least @math{2^{53}}. Larger integers are approximated. The details -differ depending on your floating-point implementation, but a common +differ depending on your floating-point implementation. +@xref{Floating point}. A common case is that @command{seq} works with integers through @math{2^{64}}, and larger integers may not be numerically correct: -- 1.7.3 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 14:21:05 2011 Received: (at 7877-done) by debbugs.gnu.org; 21 Jan 2011 19:21:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgMXg-0000zk-VM for submit@debbugs.gnu.org; Fri, 21 Jan 2011 14:21:05 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgMXe-0000zG-VF for 7877-done@debbugs.gnu.org; Fri, 21 Jan 2011 14:21:03 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 6D757601C0; Fri, 21 Jan 2011 20:28:56 +0100 (CET) From: Jim Meyering To: Paul Eggert Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <4D39D977.4030904@cs.ucla.edu> (Paul Eggert's message of "Fri, 21 Jan 2011 11:07:35 -0800") References: <8762tjcfuh.fsf@jidanni.org> <878vyek3sb.fsf@meyering.net> <4D39D977.4030904@cs.ucla.edu> Date: Fri, 21 Jan 2011 20:28:56 +0100 Message-ID: <874o92f43r.fsf@meyering.net> Lines: 31 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 7877-done Cc: 7877-done@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: -5.7 (-----) Paul Eggert wrote: > On 01/21/2011 01:24 AM, Jim Meyering wrote: >> My first reflex was to make sleep reject args like 0x... and inf. > > My reflex was just the opposite: why reject a notation > that might be useful? I see that at least freebsd's /bin/sleep and the one from sunos 5.11 work just like the one from coreutils (without my proposed change) in accepting e.g., 0x1 and inf. netbsd's accepts 0x1 but not inf. openbsd's accepts neither. > Several other programs (printf, seq, sort, tail, plus many > other GNU programs) also use strtod or strtold. If 'sleep' is > changed to reject hexadecimal and infinity, shouldn't they > be changed too, for consistency? > > I expect it's better to leave these programs alone. Not only > is this simpler, and a tiny bit cheaper at runtime, it's slightly > less likely to break existing usage. > > Anyway, whatever we do, we should document it better. To start the ball > rolling on that, I pushed the following change, which documents the > existing behavior. We can change this if we change the behavior. The above, plus your added documentation are good enough reasons to leave sleep as-is. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 21 16:36:58 2011 Received: (at 7877) by debbugs.gnu.org; 21 Jan 2011 21:36:58 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgOfB-0003wZ-JV for submit@debbugs.gnu.org; Fri, 21 Jan 2011 16:36:57 -0500 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1PgOf9-0003wN-Gk for 7877@debbugs.gnu.org; Fri, 21 Jan 2011 16:36:56 -0500 Received: (qmail 88635 invoked from network); 21 Jan 2011 21:44:49 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 21 Jan 2011 21:44:49 -0000 Message-ID: <4D39FE07.3090001@draigBrady.com> Date: Fri, 21 Jan 2011 21:43:35 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 7877@debbugs.gnu.org, jim@meyering.net Subject: Re: bug#7877: sleep takes undocumented hex args References: <8762tjcfuh.fsf@jidanni.org> <878vyek3sb.fsf@meyering.net> <4D39D977.4030904@cs.ucla.edu> <874o92f43r.fsf@meyering.net> In-Reply-To: <874o92f43r.fsf@meyering.net> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 7877 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 (--) On 21/01/11 19:28, Jim Meyering wrote: > Paul Eggert wrote: >> On 01/21/2011 01:24 AM, Jim Meyering wrote: >>> My first reflex was to make sleep reject args like 0x... and inf. >> >> My reflex was just the opposite: why reject a notation >> that might be useful? > > I see that at least freebsd's /bin/sleep and the one from sunos 5.11 > work just like the one from coreutils (without my proposed change) > in accepting e.g., 0x1 and inf. freeBSD 8.1 treats 0x01 and inf as 0 sunos 5.10 rejects both > > netbsd's accepts 0x1 but not inf. > openbsd's accepts neither. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 24 18:19:02 2011 Received: (at 7877) by debbugs.gnu.org; 24 Jan 2011 23:19:02 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PhVgc-0005hh-3T for submit@debbugs.gnu.org; Mon, 24 Jan 2011 18:19:02 -0500 Received: from caiajhbdcbbj.dreamhost.com ([208.97.132.119] helo=homiemail-a37.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PhVga-0005hH-61 for 7877@debbugs.gnu.org; Mon, 24 Jan 2011 18:19:01 -0500 Received: from homiemail-a37.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a37.g.dreamhost.com (Postfix) with ESMTP id 92E59208064 for <7877@debbugs.gnu.org>; Mon, 24 Jan 2011 15:27:00 -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=A2PHIyb5FcNrumPZwu6eSNHBj7CEjVaxKgDbSkcdKs1/aCbZg+XaGdi3pGrg v/D/KE4nY+bsyEla1+wc6uG1Xpi4QOmyvPGEjmICZWt8fgboLfdtXsMIE6P9nACB sVTbYeW3+KRAZE0FNL1lcfJP3N1cq83DaCInbcxVLRfBAc4= 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=bQG+JLyfnLlOKgDICJbZ1HiK/U0=; b=Nq/o2bDaLtJeYzZU qBdEJxZvSQJ06JtPmX4dKktiL+HZuGgfz5BL+xtfIyNHdUp15IBBYRNYttLpwNB4 ojIrM4RwiRIhSD+BkbwYVKM7+Paf3Am/RU68Z1x/HOg6+w4OLGDvFUxt9Nj5eswq Gt361QYyjofsBaPeXhXG65Bb7PE= Received: from jidanni.org (218-163-1-185.dynamic.hinet.net [218.163.1.185]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a37.g.dreamhost.com (Postfix) with ESMTPSA id 34046208063 for <7877@debbugs.gnu.org>; Mon, 24 Jan 2011 15:27:00 -0800 (PST) From: jidanni@jidanni.org To: 7877@debbugs.gnu.org Subject: sleep 5 -4 Date: Tue, 25 Jan 2011 07:26:56 +0800 Message-ID: <87wrltyjb3.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 7877 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 (---) $ sleep 5 -4 sleep: invalid option -- '4' $ sleep -- 5 -4 sleep: invalid time interval `-4' No fair prejudicing negative numbers. At least document it. 'However, GNU `sleep' accepts arbitrary floating point numbers (using a period before any fractional digits).' is what it says on Debian. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 25 03:28:41 2011 Received: (at 7877) by debbugs.gnu.org; 25 Jan 2011 08:28:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PheGW-0002Lq-1d for submit@debbugs.gnu.org; Tue, 25 Jan 2011 03:28:40 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PheGU-0002Lc-0R for 7877@debbugs.gnu.org; Tue, 25 Jan 2011 03:28:39 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 1C18860143; Tue, 25 Jan 2011 09:36:40 +0100 (CET) From: Jim Meyering To: jidanni@jidanni.org Subject: Re: bug#7877: sleep 5 -4 In-Reply-To: <87wrltyjb3.fsf@jidanni.org> (jidanni@jidanni.org's message of "Tue, 25 Jan 2011 07:26:56 +0800") References: <8762tjcfuh.fsf@jidanni.org> <87wrltyjb3.fsf@jidanni.org> Date: Tue, 25 Jan 2011 09:36:40 +0100 Message-ID: <87mxmpv0pz.fsf@meyering.net> Lines: 54 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 7877 Cc: 7877@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: -5.7 (-----) jidanni@jidanni.org wrote: > $ sleep 5 -4 > sleep: invalid option -- '4' > $ sleep -- 5 -4 > sleep: invalid time interval `-4' > > No fair prejudicing negative numbers. > > At least document it. > 'However, GNU `sleep' accepts arbitrary floating point numbers (using a > period before any fractional digits).' is what it says on Debian. Hi Dan, GNU sleep requires nonnegative numbers, so I've mentioned that in the texinfo documentation. I nearly made the s/arbitrary/nonnegative/ change to the sentence in both --help and coreutils.texi: Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. But that seemed counterproductive, since we're making the contrast between integer and FP. Adding "nonnegative" there would detract. Other implementations accept only a single argument, so negative numbers would not make sense. >From 228b7b3c85b85a14b702aac1642b931798916809 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 25 Jan 2011 09:22:37 +0100 Subject: [PATCH] doc: mention that each sleep argument must be nonnegative * doc/coreutils.texi (sleep invocation): Document that arguments must be nonnegative. Reported by Dan Jacobson. --- doc/coreutils.texi | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index ebe379e..398e20c 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -15674,7 +15674,7 @@ sleep invocation @end example @cindex time units -Each argument is a number followed by an optional unit; the default +Each argument is a nonnegative number followed by an optional unit; the default is seconds. The units are: @table @samp -- 1.7.3.5.38.gb312b From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 25 04:19:49 2011 Received: (at 7877) by debbugs.gnu.org; 25 Jan 2011 09:19:49 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Phf41-0003SI-Hk for submit@debbugs.gnu.org; Tue, 25 Jan 2011 04:19:49 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Phf3z-0003S3-CR for 7877@debbugs.gnu.org; Tue, 25 Jan 2011 04:19:48 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 08C4F39E80E0; Tue, 25 Jan 2011 01:27:50 -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 KM9b2-R4EwRP; Tue, 25 Jan 2011 01:27:49 -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 855D239E80DB; Tue, 25 Jan 2011 01:27:49 -0800 (PST) Message-ID: <4D3E9795.6010804@cs.ucla.edu> Date: Tue, 25 Jan 2011 01:27:49 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#7877: sleep 5 -4 References: <8762tjcfuh.fsf@jidanni.org> <87wrltyjb3.fsf@jidanni.org> <87mxmpv0pz.fsf@meyering.net> In-Reply-To: <87mxmpv0pz.fsf@meyering.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 7877 Cc: 7877@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.9 (--) OK, so it's late, but I can't resist: First, 'sleep' does accept one number that's negative in an IEEE-754 sense, namely, "sleep -- -0.0". Second, due to rounding error, 'sleep' does accept some numbers that are negative in a mathematical sense, e.g., "sleep -- -1e1000" works. Third, there's nothing intrinsically wrong with 'sleep' accepting negative numbers. All that POSIX requires is that 'sleep' must sleep for at *least* the amount of time specified. So, if "sleep -- -1.0" is treated like "sleep 0", then it's conforming to that requirement of POSIX (obviously it doesn't conform to the other requirement that the operand be a nonnegative decimal integer; but it's a valid extension that is consistent with POSIX). (Have I written enough to tempt you to extend 'sleep' to allow negative numbers? :-) From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 25 05:46:40 2011 Received: (at 7877) by debbugs.gnu.org; 25 Jan 2011 10:46:40 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PhgQ3-0005Li-47 for submit@debbugs.gnu.org; Tue, 25 Jan 2011 05:46:39 -0500 Received: from caiajhbdccah.dreamhost.com ([208.97.132.207] helo=homiemail-a38.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PhgQ0-0005LU-Ns for 7877@debbugs.gnu.org; Tue, 25 Jan 2011 05:46:37 -0500 Received: from homiemail-a38.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a38.g.dreamhost.com (Postfix) with ESMTP id 294D110AFBB; Tue, 25 Jan 2011 02:54:39 -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=m1iREwHdR76Kptzndye4Gvey3Whk+d7Pxvx9PedOvDE/xiC7Y vNxsZ5W7QGDKVugtlkdXWDhK9Ao7DS+As/IPCx0sJBc+72vDL2jqmbxm1Ti/YZcW 4tumUT1nRGQpVmcec3yrqBCXRb9/GuuRGGpLQn3hRuqe8HzNHula6laxFU= 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=ZtxCVHW9Q8NGcBWwUKkrxCKXqnU=; b=VUrJmZQWE/GE8 U5HtvVznUB4XslXd+fPlGEMGkVQatHyFqjJ+MMsicmr5r57Ch39Y75Mko3sm2A0o MFkTsDAadSZyr5I+gFrcV1t2rAwCGEKwGKt0G5Ir0OLDiyYqr+iS52sbu9ARq2CX f0alr8nAY9Xqv8bca+qvmr5CcN/yMM= Received: from jidanni.org (218-163-7-68.dynamic.hinet.net [218.163.7.68]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a38.g.dreamhost.com (Postfix) with ESMTPSA id 5A66C10AFB7; Tue, 25 Jan 2011 02:54:39 -0800 (PST) From: jidanni@jidanni.org To: eggert@cs.ucla.edu Subject: Re: bug#7877: sleep 5 -4 References: <4D3E9795.6010804@cs.ucla.edu> Date: Tue, 25 Jan 2011 18:54:35 +0800 Message-ID: <87tygxdzis.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, jim@meyering.net 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 (---) >>>>> "PE" == Paul Eggert writes: PE> (Have I written enough to tempt ... to extend 'sleep' PE> to allow negative numbers? :-) Right you are young man. We here at NerdLabs already use $ sleep -- -100 to give us a few moments to go back and correct errors. But due to National Security, that's all I can say, except that one shouldn't make assumptions about what future generations might want to do... From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 25 06:20:28 2011 Received: (at 7877) by debbugs.gnu.org; 25 Jan 2011 11:20:28 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Phgwm-00069n-A5 for submit@debbugs.gnu.org; Tue, 25 Jan 2011 06:20:28 -0500 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Phgwj-00069Z-5C for 7877@debbugs.gnu.org; Tue, 25 Jan 2011 06:20:26 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id BD2EA60472; Tue, 25 Jan 2011 12:28:28 +0100 (CET) From: Jim Meyering To: Paul Eggert Subject: Re: bug#7877: sleep 5 -4 In-Reply-To: <4D3E9795.6010804@cs.ucla.edu> (Paul Eggert's message of "Tue, 25 Jan 2011 01:27:49 -0800") References: <8762tjcfuh.fsf@jidanni.org> <87wrltyjb3.fsf@jidanni.org> <87mxmpv0pz.fsf@meyering.net> <4D3E9795.6010804@cs.ucla.edu> Date: Tue, 25 Jan 2011 12:28:28 +0100 Message-ID: <87d3nlusrn.fsf@meyering.net> Lines: 35 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.8 (-----) X-Debbugs-Envelope-To: 7877 Cc: 7877@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: -5.8 (-----) Paul Eggert wrote: > OK, so it's late, but I can't resist: You obviously need to, er... sleep. > First, 'sleep' does accept one number that's negative > in an IEEE-754 sense, namely, "sleep -- -0.0". > > Second, due to rounding error, 'sleep' does accept some > numbers that are negative in a mathematical sense, e.g., > "sleep -- -1e1000" works. > > Third, there's nothing intrinsically wrong with 'sleep' > accepting negative numbers. All that POSIX > requires is that 'sleep' must sleep for at *least* the > amount of time specified. So, if "sleep -- -1.0" > is treated like "sleep 0", then it's conforming to > that requirement of POSIX (obviously it doesn't > conform to the other requirement that the operand be > a nonnegative decimal integer; but it's a valid extension > that is consistent with POSIX). Maybe there is a use (albeit far-fetched) for negative numbers. Let's say you want to sleep for 5 seconds less than a day. Which would you prefer? This: sleep -- 1d -5s or this: sleep -- $((24*3600 - 5))s > (Have I written enough to tempt you to extend 'sleep' > to allow negative numbers? :-) I would accept the change. Do you feel like writing it? From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 28 00:51:04 2011 Received: (at 7877) by debbugs.gnu.org; 28 Jan 2011 05:51:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PihEd-0001ms-V7 for submit@debbugs.gnu.org; Fri, 28 Jan 2011 00:51:04 -0500 Received: from eagle.jhcloos.com ([207.210.242.212]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PihEa-0001mK-Rw for 7877@debbugs.gnu.org; Fri, 28 Jan 2011 00:51:01 -0500 Received: by eagle.jhcloos.com (Postfix, from userid 10) id C55714011E; Fri, 28 Jan 2011 05:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jhcloos.com; s=eagle; t=1296194351; bh=Y6uAPaZLsCgH1DRpPfRM8pCzDcOOSTTphIYhdxnxX7Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=AapkQKgotmVNnDE3XtVRPDNsxmSjUTx0bwHR5w5pVw82VPeoI3vRsP6pEH3Y6pGKd C6d0gp6PMipSSl2bY6XyTPueTAI0e+AJQ+0VtKS1GS9vXXLmczCyCYlJRtxLW+tHwM v/ufxj2wRjI1sRFJDR2kIIfKn7RXYW3RGjKIa9MM= Received: from carbon (localhost [127.0.0.1]) by carbon.jhcloos.org (Postfix) with ESMTP id C6275360029; Fri, 28 Jan 2011 01:00:40 +0000 (UTC) From: James Cloos To: Jim Meyering Subject: Re: bug#7877: sleep takes undocumented hex args In-Reply-To: <87aaiugv87.fsf@meyering.net> (Jim Meyering's message of "Fri, 21 Jan 2011 15:57:44 +0100") References: <87fwsmij1o.fsf@meyering.net> <878vyebey9.fsf@jidanni.org> <87aaiuif2q.fsf@meyering.net> <4D399D7E.1060103@redhat.com> <87aaiugv87.fsf@meyering.net> User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAI1J REFUOE+lU9ESgCAIg64P1y+ngUdxhl5H8wFbbM0OmUiEhKkCYaZThXCo6KE5sCbA1DDX3genvO4d eBQgEMaM5qy6uWk4SfBYfdu9jvBN9nSVDOKRtwb+I3epboOsOX5pZbJNsBJFvmQQ05YMfieIBnYX FK2N6dOawd97r/e8RjkTLzmMsiVgrAoEugtviCM3v2WzjgAAAABJRU5ErkJggg== Copyright: Copyright 2011 James Cloos OpenPGP: ED7DAEA6; url=http://jhcloos.com/public_key/0xED7DAEA6.asc OpenPGP-Fingerprint: E9E9 F828 61A4 6EA9 0F2B 63E7 997A 9F17 ED7D AEA6 Date: Thu, 27 Jan 2011 20:00:40 -0500 Message-ID: Lines: 18 MIME-Version: 1.0 Content-Type: text/plain X-Hashcash: 1:30:110128:jim@meyering.net::aL0IErTQVbH1irEH:dpqnA X-Hashcash: 1:30:110128:eblake@redhat.com::FIv4gQYN7jj6U5N6:0000000000000000000000000000000000000000000xHMeR X-Hashcash: 1:30:110128:7877@debbugs.gnu.org::NsYmUO5Tkvq9swAt:0000000000000000000000000000000000000000ftt0M X-Hashcash: 1:30:110128:bernhard.voelker@siemens-enterprise.com::cqr6YIMHTONfWiNh:0000000000000000000006Ozja X-Hashcash: 1:30:110128:jidanni@jidanni.org::OXPaYZGYJ7IqOKb0:000000000000000000000000000000000000000000P0Rb X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 7877 Cc: 7877@debbugs.gnu.org, Eric Blake , bernhard.voelker@siemens-enterprise.com, 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.8 (--) >>>>> "JM" == Jim Meyering writes: JM> I see no significant utility in accepting hex floats. Do you? JM> If you're concerned about errors in conversion or the efficiency JM> of the conversion process, then you probably don't want to use JM> the sleep command in the first place. the reason would be those cases where hex float literals are the default output format for some given language. I don't know that any exist now, but I also don't see any reason to preclude them. Hex floats are, generally speaking, a nice progression. -JimC -- James Cloos OpenPGP: 1024D/ED7DAEA6 From unknown Sat Jun 21 03:25:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 25 Feb 2011 12: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