From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10409 invoked from network); 4 Nov 2022 03:18:31 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Nov 2022 03:18:31 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1667531911; b=lDMXLi6KT0HczWbk0CPQrU6wXHXcwK+OzdCgV7pV+HNfn+mdoPLMguMfHmBkHTRkZJTzSsVWQ1 WJUjlIa+K+IJxAm1z1mOqLLqukAvG3eYK3HypmegwCwxaiN+TSOtX99WufpYM4xHJg8D0IPthQ cjEY92lbJTH0vrO/85mmXgs3TXhUf3crDYKLh5ZMRRMbse5NFWhXlnPS5kNJ4Q4tlZVyusWpHG ifsGGp4ljgTWwTJFSAv94OzHAJ7bXXyOSVGdl9NxPSWV9xkFRjr71QRTzJEccJAabVisNzdqf2 wmL6xzvnEVBT/Fq3KBFo5h1OCv9mOOMEIMgHl1bpdY3XTw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout2-smtp.messagingengine.com) smtp.remote-ip=64.147.123.25; dkim=pass header.d=dana.is header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=dana.is; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1667531911; bh=X/yRAYXBt60RkJL4JLJpiYbakm3zt8ehyWvUAKskS/8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:Cc:To:From: Date:References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=lqFni42KO6NSkvu6momjM0UzH5RJuf06PC4pLaOjYTs4V6jXx+L8g9QIPD1jiUMfr+4F8PUrya dBMvsRyubNzRCvfR2ZrMaVP/yy5SgGWPnEMEFrKgRntfZeIIHKRzmM/tqPT37QvF28tzwPWtOj kLPUUhrceorTS4rMHYnQCa/WM5yQVZltUREa6DG2lOjVEtTE+JMJuDhEXrwMRkcNN+kS/l0zTc DwzugIzJ4pVfMoPZv6AdNih3ItDjpBhpkpQR48NteOLKG4Xxb4wSfS7g78FQ0RDP3IfvWE5KLB aWID3gueGGJdY3P9hgl+z5TxYaJVugf2cRwQMHAJ564ICw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=lv/6Ym+Ww46EwqShg83ZvXnyWKYScOv8uB72s4eRiaw=; b=aChVb3XfBXcZ/p+R3xwQ2T3oQt o4hlzqYLRoiLD4npLpoUGBj+UuthZgITLJZoYj3ETReMZVlnXkDAOiG+L3wLwpcMDZmUHHCcCZZTx /CQI/SfZ3TdyjHuIc8C/BSkTJLFHfCkOFpM8EVgBc85UqsoUE2Dis/p2tlp41GhJbXBuEZiqKg5dc +wga6vNY3GSKh1QHgOQIkPo18JVZFB+DUkyOzULPLN3UXmGHFrlYrYE5PryFnUtvI1rLojkodz44g SAC3ZPYaw0fEV2xSTzqoECJw8KesTkpR6EG6GLkfIuVtKyHRZc3iyG+p0tV/4PbqLnG61FoUarkFi KGPyA5DA==; Received: by zero.zsh.org with local id 1oqnDx-0003tq-8b; Fri, 04 Nov 2022 03:18:29 +0000 Authentication-Results: zsh.org; iprev=pass (wout2-smtp.messagingengine.com) smtp.remote-ip=64.147.123.25; dkim=pass header.d=dana.is header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=dana.is; arc=none Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:44545) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oqnDJ-0003Yz-Mc; Fri, 04 Nov 2022 03:17:51 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id C113E320070D; Thu, 3 Nov 2022 23:17:46 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute5.internal (MEProxy); Thu, 03 Nov 2022 23:17:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana.is; h=cc:cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1667531866; x= 1667618266; bh=lv/6Ym+Ww46EwqShg83ZvXnyWKYScOv8uB72s4eRiaw=; b=W C2WZV0NG2HeLRpiM5TViB8iLhPINAhWv4g+bxUZM6NHI5EsDECoMneuNWVJAE9kL WN09/7+fMVIVIXeqz0S4TFByN5Uad5ILbHyINweSGmmuISzWjqF0Xq5dywxpDhiO qSpNP4NUG7P3fSpdGYDMig6aH0AUH3++JO0FnFSeg62SjwUFtyoe8PHtDgi1X05X UE0kCOK+kWoe/hLXggJ8hA/AhQGDCmJtANfKix9vQYUcKnuK1tJnT6S1YO2RAfHJ DMfJH6Ckn9winSB8Q7oaRCa8fnGv67Cq1xkDkJkLtwhson7mKJxG3X1Y+3S5JUXi J2KUqnGwCP6bQ3GO5MR+A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1667531866; x= 1667618266; bh=lv/6Ym+Ww46EwqShg83ZvXnyWKYScOv8uB72s4eRiaw=; b=a MXl9xV5Mgs/LPj1UQbkM9Y/yzMGz8IBEgU9K06GYBfpSTsr8LGYv5wfV8/X/RtnA 8rYj2fa1FfCasm2CINjE6YjHv/Z4L2ZnLASxgpsZNEuVvtuRxIWEyJE7EN2+Db7B WCxWasTxKuDzpvX0lkc48k2MYuLE5XalgMsQHYstuiDpGVSGeYwQuY2eVSem1EyL 7cy1dzxtalevAoNO7KletPaHQOXtHoux2e5zFv3+mKoEhFtcuB7qORIVFqdOwQpe pro1p+Kg23O2X8vLqIpLDhAJ6VqSbnjOCFKk+rWmI/Y8j3qx0XRe43lLqkmfD4Lg zgXepqnkfQdcCk5yvYNyw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvddtgdehjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvfevufgtgfesth hqredtreerjeenucfhrhhomhepuggrnhgruceouggrnhgrsegurghnrgdrihhsqeenucgg tffrrghtthgvrhhnpeetvdekffeuteeiveevkeffhfdtgeduueduiefgfefgueektdfgtd ffheefuefhueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegurghnrgesuggrnhgrrdhish X-ME-Proxy: Feedback-ID: i9be146f9:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 2CC7A1700090; Thu, 3 Nov 2022 23:17:46 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1087-g968661d8e1-fm-20221021.001-g968661d8 Mime-Version: 1.0 Message-Id: In-Reply-To: <741b77be-b679-76cc-f8ec-49c9d89323c1@zentaur.org> References: <741b77be-b679-76cc-f8ec-49c9d89323c1@zentaur.org> Date: Thu, 03 Nov 2022 22:17:24 -0500 From: dana To: "Clinton Bunch" Cc: "Zsh hackers list" Subject: Re: [PATCH] zsh/random module Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 50861 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Wed 2 Nov 2022, at 12:13, Clinton Bunch wrote: > I'd appreciate if someone would test it on a few other platforms and t= ry=20 > to break it.=C2=A0 I tried everything I could think of, but... I like this idea, i've wanted to do something like it for a long time. It seems to work OK for me on Catalina as well Here's my feedback. Sorry if any of this came up in previous discussions= . I also didn't look super closely at the code, just skimmed it for high-lev= el stuff, so idk about the security, portability, &c. API/behaviour: The default length behaviour with -i is weird to me. I get that there's a certain internal consistency to it, but i feel like 95% of the time if y= ou want a random integer you only want one, right? Would it be less confusing to refer to it as 'count' (-c) or 'number' (-= n) instead of length? Maybe it'd be easier to understand that it means byte= count (not string length) in the default mode and element count in integer mod= e? I guess programming languages often overload 'length' to mean different th= ings like that, though, and people get by OK with it zwarnnam(name, "argument to -s not an identifier: %s", scalar); zwarnnam(name,"argument to -a not an identifier: %s", arrname); Seems like it could just create these for you? I'm not aware of any other built-ins that take a parameter name that treat non-existence of the par= ameter as an error (except for like typeset). See for example printf and sysread zwarnnam(name, "-r can't be specified with bounds or -i or -a"); I can't think of any reason -r couldn't work with bounds or -a. The latt= er in particular seems useful, though easy enough to achieve with parameter expansions i guess. Making it support bounds would let you do things lik= e only return random ASCII letters Tests and a completion function would be useful Documentation: +Set the length of the returned random data. Defaults to 8. I feel like it's not immediately clear what 'length' means, due to how it behaves with -i. I wasn't sure i was understanding until i just tried it= for myself. Maybe add something like '(in bytes or, with -i, number of integ= er elements)'? I also agree with Bart that it makes sense to put -L before -U. Makes se= nse to alphabetise option lists in general imo, though this wouldn't be the fir= st built-in in the manual that has them out of order And i think all of the descriptions should be either indicative ('does x= ') or imperative ('do x'), not a mix of the two. Though again this wouldn't be= the first to mix them Typos, white space, consistency issues, &c.: Some typos i noticed: +Some High-quality randomness commands, parameters, and functions. * places them in an outbut buffer twice the size. Returns -1 if it ca= n't. /* Vailues for -U *nd -L */ "length must be between 1 and 64 you specified: %d", * Provides for the SRANDOM parameter and returns a unisgned 32-bit ra= ndom /* Check for the existence of /dev/urnadom */ zwarnnam(name,"-i only makes sense with -s when 1ength is 1"); zwarnnam(name,"Upper and Lower bounds cannot be the same."); git complains about trailing white-space on lines 23, 32, 48, 55 Lots of random double-spaces all over Inconsistent white space around operators, commas, e.g.: zwarnnam(name,"Couldn't get random data"); but then zwarnnam(name, "-r can't be specified with bounds or -i or -a"); Inconsistent indentation in several places, usually spaces where there s= hould be tabs (Ctrl+F eight spaces) Weird error message, not sure what it means for data to fail: zwarnnam(name,"Random Data Failed"); Some error messages use sentence case, some don't dana