From nobody Tue May 24 07:55:40 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1D44C1B38E26 for ; Tue, 24 May 2022 07:55:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L6mhr6kVpz4pNk for ; Tue, 24 May 2022 07:55:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C3CB4208D9 for ; Tue, 24 May 2022 07:55:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 24O7tep7017043 for ; Tue, 24 May 2022 07:55:40 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 24O7teQ4017042 for bugs@FreeBSD.org; Tue, 24 May 2022 07:55:40 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 264162] /bin/sleep: Add optional units (seconds, minutes, hours, days) Date: Tue, 24 May 2022 07:55:40 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: se@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc flagtypes.name Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653378941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1b2ZgE4PJtpnyJa1i695M9HjG6YFoDK83m+e2BhMla4=; b=nEUUhFzth8S7cQdSH/ZDVIPWvnKvNOCR9RY7ACbZVZqomTdPrBVdbTybtI27r+rzzO9OwY E5b5Mxna50QrWe2D/CYRJpJkoeFRlBjbT27XhUPYzLc+VO6xPRyJ3zkQoBNvPmcA0sOQ4I Wtgzt+OAMolaGh3VZruEDGk/zbiIP7ujHxE3xXTlj4pJpNMhtNNoRFU7yZrqU6HN8vSK9f mAGPLJH2HGPt8+AGbMNU7w0rKXgxAYqDjlHc2dtT01a1Gou9OZrUfQXSM7V7eO1r+hLRiq HdnhQgq3Dah00PdBkMGrjmwww5PH3XcEv6wSw+s8dEY+XZ6TsRq7MyxXOHOIdg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653378941; a=rsa-sha256; cv=none; b=w6xQnQTS/U6xNyjnlQIPVV/ID/ArEiW8tinfCi+ElSHFVLvWD1iBl5cY/toMGWeK1F05Hn cxdhMnbuPy/EdOVsbAD4suTitUK77QQWMakcpOOcPM7rgVxjpTQxMQ3enwTRnvNhuOYdHc 1GGD3ClmdJLhGxHzITWcB9HKFcbJZWToahkmodeIZDOPmQUbrP8ql8/BsQH+1jzZYNP/yt m+rKUz8u8GHwa2jRBehk2D/FZjEDCyVVJ/g41PbjgDXcqPwFRlFG78vXDEmNBXT1nNGyBL BHKpDWCCvN+xaMXUfnFP7xY8kX1eLtJvH3udS0VWZwDEeiwLWWeSebjUHD5tLA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264162 Stefan E=C3=9Fer changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |se@FreeBSD.org Attachment #234127| |maintainer-approval+ Flags| | --- Comment #1 from Stefan E=C3=9Fer --- Comment on attachment 234127 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D234127 Allow passing optional units (seconds, minutes, hours, days) to /bin/sleep Thank you for the contribution! The patch looks mostly OK. I would have used a variable to catch the number= of patterns parsed by sscanf() instead of duplicating that call, but this is a technical detail. There is one issue, though: if (sscanf(argv[1], "%lf%c%1s", &d, &unit, buf) !=3D 1) should be: if (sscanf(argv[1], "%lf%c%1s", &d, &unit, buf) =3D=3D 2) The !=3D 1 test detects the presence of an extra argument following the num= ber, but does not reject the case of more than 1 character following. Testing for 2 patterns matching makes sure that there was just a floating p= oint number followed by a single character. This catches the case of e.g. "1sx" being passed as the argument, since the extra "s" would be parsed as a 3rd match. I'll commit the patch with the test of the first sscanf() changed to "=3D= =3D 2". And I'm considering to add a loop to add up multiple delay values being pas= sed as is done by the coreutils version of sleep, for full functional compatibi= lity with that version, in a follow-up commit. --=20 You are receiving this mail because: You are the assignee for the bug.=