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=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4587 invoked from network); 23 Nov 2022 19:52:44 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Nov 2022 19:52:44 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1669233164; b=i23EYNGZnhbhWMtNpXYXP8L0Z++maA+rVTTsUHLwH+H+hwgb1fsvdbJU5nCmcXUQflWU9whTu+ FUkDr6aqfs1+IX2Cbx/oVoBqyKuVle927M7UZmMShbfMStjtyyCq/tjikJxToS70taP2TFkA8A PSZlTZ7M6pzXyw7EzohvTYQLt4Wjj6DQs5DUTTV04vAU49xsNCsOfgLm9gy2fST3/orste/8cs AD0Sq1x/5N7tyN2sRGt3q84E4RACYzH5lDA9rXkqrDLN9hKemEIuVb6A57XDWI7q7DtAuo4XAr CA1lmuYzvrOAlzwtcHmrPZqDe+F/ECUZFt8sZ7IRjxuNkg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.25; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1669233164; bh=VlXk99X6bZJtwP0/ZbygJJIME1BuQ1rDRKwmy1CXsZs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=SQrWotTDzWoTeTVY+p1me5+YyPiEGbMdTA6L/vMllikUQGwL7FCY8GAnFb6QL89VhZlq1Rln75 F1YmhrjaV2IYCPFkFphJ7Bt1cnIiktnkITque+E0lroiEzsXehVtvJIVXFkROd6TENFsHD/ZAt Xb9SO6TaoFg73It6u8R+3unvK7KHBBQVu671Q4rIlCq/A04RTb4nBtlbpjqWzICeXmFms26Xp2 uZQyGB4Svajxcur2Hz2t1K/qK+LrJnO+5cEfmBEd7fR5Hd5Vslz+vEryMDA8iBLXGg5uiv+j51 bz0ZXRlFKVyfZ2xtcuYeHpXZq23ZPTsxVe+I3VdyJ/SVzw==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=6bYqTItxRWfjrieoVhn7kbxFiDAmMJCQWLnn4qdSc6Q=; b=sOfpIG3MzpaZ71sti9TldgnDTY E2qXmsJlyL1WlL8lyVaXVG6C0gzh4naj4SKZoeIz8nxuu4cumC7ty2fJ16dKgbwKhB0uRJVxLRquH P7brizMGYmeVjQkStN4X9ICDgM4ip2IN/LXvkqgT0RjM/fGxTsWRLOgG62r6UYJASasaew0qfkC43 WjGSpthORRxIUNolt4JAI6ChfFRsp4tEs1eMUS6ecILf472JIUgTrZFxxHr38BFAt+yPJCrI7WFbG TZ9jlofxV+CVwQ5VJ6124qc2xgD2MDmJQOJDTDvtp2z9967B1czQ5LOBgW/4Ua1qqmDLHe8Y51ApR YEBK0EMg==; Received: by zero.zsh.org with local id 1oxvnX-000Lsb-Vn; Wed, 23 Nov 2022 19:52:43 +0000 Authentication-Results: zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.25; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out1-smtp.messagingengine.com ([66.111.4.25]:53065) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oxvnF-000LUo-7b; Wed, 23 Nov 2022 19:52:26 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 832A35C00EE; Wed, 23 Nov 2022 14:52:24 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 23 Nov 2022 14:52:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; 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=1669233144; x=1669319544; bh=6bYqTItxRW fjrieoVhn7kbxFiDAmMJCQWLnn4qdSc6Q=; b=uXMqgDEMpXiC3agNrh6hz6bWWk HAhaouKdtgRJ7JcgiglCtWkYckutrEj02XFFiGqzD82Ea0NkTf2rQDdHFsdnGZrf PGzrCKOICO6slomUtNe8xJCfViFWMhzmPpF53FmszOfpBx1VCcTjVbC3ldYamIUn nvRJD58IlAfxPDCBRm3Efsy8rvTfMC/WAK3Ydwg9vMsvFlkDwtDbmf5STNuvqRV3 ay5jiJIfGx45WXAPNb3hBXowUVG7bzz+wvFX4PNsbsZbVG1siz7qzJy2ETEomvjU USRWXqJecNwbrX84dLHn71eYUgOYbTYg+BHPvT86nS5FaLR0Tgoq7blNgHIA== 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=fm1; t=1669233144; x= 1669319544; bh=6bYqTItxRWfjrieoVhn7kbxFiDAmMJCQWLnn4qdSc6Q=; b=N wIg/9275f7TSs1bkiZjOYUzNClTNHblx5B+CpBHbqkLWbCBT1vxt33Jn/S40DLYv /VcQx3FkzIJObe+0LdRKiu7tNxavppap83VDXvL7a94lpPaw5uUaHjG97B2IHxAN 9H/eQ75gHqvxAA0qMnimplNDRtoR3PXAgC+B4lHj2nEQepuLghVsHCGagmPD1vNW B3PlNe/sXqOR70uWvr4VGrXn5rTYWEWsWPcRXg65z4CoDVvX+OVC9fAHigBwgBPc BURYxVSrM1mtf7nou0St08OvQx/TMXA4zMULPCwYocwCodOn4wmD/+7gNgOdb29B khvFxUr1+/lbnRt4CASQw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedriedugdduvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjfgesthektddttderudenucfhrhhomhepffgr nhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg eqnecuggftrfgrthhtvghrnhepfefhieeutdehgfetudefveeitdegtdejkefgvddugffg tdduheeggfejudetfeeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 23 Nov 2022 14:52:24 -0500 (EST) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4NHWxL3JGbz38Z; Wed, 23 Nov 2022 19:52:22 +0000 (UTC) Date: Wed, 23 Nov 2022 19:52:22 +0000 From: Daniel Shahaf To: Clinton Bunch Cc: zsh-workers@zsh.org Subject: Re: [PATCH] zsh/random module [UPDATED] Message-ID: <20221123195222.GO27622@tarpaulin.shahaf.local2> References: <741b77be-b679-76cc-f8ec-49c9d89323c1@zentaur.org> <1e8ea669-7a25-b321-6024-72dbc43ac023@zentaur.org> <41205a86-8aad-4821-baa4-1d2ac9bf3c5d@app.fastmail.com> <1b2cafe6-b4b5-c59a-11f3-4dbc1e99e2bc@zentaur.org> <6275a5ac-3a47-f591-7b3c-380ec4fed5ac@zentaur.org> <20221118162325.7i3qzqljyx4a7z3h@chazelas.org> <20221118181253.cdejvepmnsmia7jm@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 51038 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: Clinton Bunch wrote on Fri, Nov 18, 2022 at 12:38:26 -0600: > > On 11/18/2022 12:12 PM, Stephane Chazelas wrote: > > 2022-11-18 11:08:42 -0600, Clinton Bunch: > > [...] > > > > Some comments about the API: > > > > > > > > > -c COUNT > > > > > Sets the number of returned random data. Defaults to 8, > > > > > unless -i, -L, or -U is specified without -a, in which case > > > > > the default is 1. COUNT must be between 1 and 64. > > > > Why those arbitrary limits? Why not from 0 to inf? > > > the getrandom function only guarantees 256 bytes.  64 32-bit integers. > > > Allowing 256 uint8 would be possible, but harder to explain and doesn't work > > > well with bounding.  As the difference between the lower and upper limit > > > surpasses half the max, the number of bytes thrown away to allow uniformity > > > of distribution becomes unwieldy. > > > > > > Also zero would not be particularly useful :) > > You could call getrandom() as many times as necessary. From a > > user point of view (mine at least) that limit doesn't make > > sense. Users don't care what API you use underneath. > > > > An array can have from 0 to inf elements, a string 0 to inf > > bytes, I should be able to request from 0 to inf numbers/bytes to > > store in my array/string. > I can't do inf (there is a limit to how big an array can be, the largest > integer for an index).  I honestly think it's unlikely anyone will need more > than 64 random integers.  I saw no reason to expand the limit, but it can be > done. > > > > Without -i you get uint8 in hex and with -i uint32 in decimal. > > > > Why the different bases? > > > It's possible to break a hex string into bytes in a rather straight forward > > > way.   A string of decimal numbers not so much, but decimal numbers are > > > easier to manipulate. > > > > > > If I didn't think it should do *something* when given no arguments, I'd > > > eliminate the hex string altogether. > > Alternatively, you could add a -f %02x, -f %u -f %c and do > > without the -r/-i, with default -c 8 -f %02x -L 0 -U 255. > That seems a lot more confusing than -r (raw) or -i (integer) unless it's > expanded to a lot more arbitrary formats.  At least for someone not familiar > with printf formats. Could have something like this: "-f:specify format:(raw hex decimal)" It's extensible and readable. (Could easily extend it to support printf formats, or uppercase/lowercase hex variations, etc..) Also, it uses one fewer short option :)