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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32631 invoked from network); 4 Nov 2022 06:23:59 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Nov 2022 06:23:59 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1667543040; b=aRPAV439FXqTzEjsyaMXHJMUmK8kfgarza2fNw8ohbl317yLfXhO4t6Ix4eejfYA4U8tE9dIQM YIY9FLyyyQGILVPCA6aoEQxn8iwE139Dut7PhlplU3GvhYsB3UF/ugfFGTIiDinX+QOyiOjmRY cuk+LvgAzx/KGtAxNROfd3DzvMF1yFHwGdNuQnaK2k9NNbyYJwhJ9gt8IK60EfTufi5Bke8cXZ XEou5/SrN44Omi3bX0smwHryMROcoethal30nT5lhm+QPo9Pkc2bp1wG/47rlejcjJ2N/EUyBV jjfLPD/SkxFWrSPUFMJhjVXOhaGcWZXhPIEGL8AWsEq81Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1667543040; bh=4jNL1T1w+7bluJ5OpQGqU0UiwdQfNvQcehksWSTPJvk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=D9KxL1Se5Vwp2pDiQod9b4UPusYPrQCo92ClwT+UU2nIJwR93uNvmgm3Dxf4je7GxmMvtR/zPE DSYOJSSZgaPXeFPBQVjtM7zxiTohzqTyVONsTTXQQlsnwFHVjeEgOyjdmemVO+QUuPoBlKoKM3 bplT606bijHE36nfHnYMtUO7gbBpGVGoDWitg2PwbpW+u57Y0si/o0NTR6IhHtvNN4PwFx9wAM dJMGbNJ4eFf0V+3KRvHfGdWwAZUxQ/YutnVSviZImPfZHWce/UAanant3uYqVhi8gb9sLKSShe HvWidvX7VqXglKivOCdnmcmcnlueZEfLD1wUgJyyQkV6bg==; 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:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=akaBxUZxbTRW7hJxI/qhR6T9M7wW4gKV6q7b5eTtSlg=; b=Oe6Oxyh7KQ7kajhP4xil/XxfhG uGSu+jOfisq9RqIHiFG9RVDGPMPIFwnY4B0lgR/49VXM3XwQQQ01ozQioblPJNft0Cogf5Dp4suzf rBnGPYT+hK9w4FWnW5ZODr58ROMACPGjXjgaPxtA9AaEwiGaRPdmxu6geZ6WuYby9mietHVra7pv5 izGXfUROovkDONvQhxSJ87iVHRh7fLxMKZXrpKjLuJh4EpyJENKaShqEfbMhyAoH0cvimnAtA1KKB MtrQFoIVtFb411zxmvUurKwQnb5e/s25ddAvQ9d37GRWzCxMh9GkEa9oDaL6ggTf5Z55pelcmJLax NoLPe4tg==; Received: by zero.zsh.org with local id 1oqq7S-0009Lc-FZ; Fri, 04 Nov 2022 06:23:58 +0000 Authentication-Results: zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none Received: from iris.zentaur.org ([198.58.127.206]:37442) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1oqq5u-0008zX-Mc; Fri, 04 Nov 2022 06:22:25 +0000 Received: from iris.zentaur.org (localhost [127.0.0.1]) by iris.zentaur.org (Postfix) with ESMTP id 4N3VsT2nn4z3wZj for ; Fri, 4 Nov 2022 06:22:21 +0000 (UTC) Authentication-Results: iris.zentaur.org (amavisd-new); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=zentaur.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zentaur.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:references:to:content-language:subject:subject :user-agent:mime-version:date:date:message-id; s=dkim20200120; t=1667542940; x=1667546541; bh=4jNL1T1w+7bluJ5OpQGqU0UiwdQfNvQc ehksWSTPJvk=; b=SUfQ3DBfap9bkORAkXmuDdFkoDpZTCfaKocfTmaqbZ0DTqoo bZrTr/CXF0SJh+9Q/WM4RKszcdvMdCf4vhkD60OwMAYxZIVaEOjK3tuEYpe26THA buZSMj1UBPi3ra0v++dk56SswoOll85298R3t9IE25FFHR6o2JngJBJD3XDg3s0m Sn81G6CHzUw6zQpSHkj8I9o8Rp1alPEw4xWtLr0IxZZl0EaP6rm9/1OSxCKXnFyP gFfRWiPAD42fvhEJGbnN9R0WvirRl9kgVAn2AwU4LiO/a/eO29w09rHBbra/bwDj 5Ksu27vd1Ph1+aEv6xUhGrjKIcbWPcTarYgDRg== X-Virus-Scanned: amavisd-new at iris.zentaur.org Received: from iris.zentaur.org ([127.0.0.1]) by iris.zentaur.org (iris.zentaur.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pJ4XiOYgrZlC for ; Fri, 4 Nov 2022 06:22:20 +0000 (UTC) Received: from [192.168.72.136] (unknown [136.50.213.220]) by iris.zentaur.org (Postfix) with ESMTPSA id 4N3VsS2P1Qz3wZb for ; Fri, 4 Nov 2022 06:22:20 +0000 (UTC) Message-ID: <1e8ea669-7a25-b321-6024-72dbc43ac023@zentaur.org> Date: Fri, 4 Nov 2022 01:22:00 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH] zsh/random module Content-Language: en-US To: zsh-workers@zsh.org References: <741b77be-b679-76cc-f8ec-49c9d89323c1@zentaur.org> From: Clinton Bunch In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed X-Antivirus: Avast (VPS 221103-8, 11/3/2022), Outbound message X-Antivirus-Status: Clean Content-Transfer-Encoding: quoted-printable X-Seq: 50863 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 11/3/2022 10:17 PM, dana wrote: > 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 >> 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 discussion= s. I > also didn't look super closely at the code, just skimmed it for high-le= vel > 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 = you > want a random integer you only want one, right? Then why would you use the builtin in preference to the parameter SRANDOM= ? > > 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 byt= e count > (not string length) in the default mode and element count in integer mo= de? I > guess programming languages often overload 'length' to mean different t= hings > like that, though, and people get by OK with it I could see count instead of length, since length is more commonly used=20 with the string mode. > > 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 oth= er > built-ins that take a parameter name that treat non-existence of the pa= rameter > as an error (except for like typeset). See for example printf and sysre= ad Copied that pattern straight out of Src/Modules/datetime.c > > 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 lat= ter in > particular seems useful, though easy enough to achieve with parameter > expansions i guess. Making it support bounds would let you do things li= ke only > return random ASCII letters raw mode isn't something I would think of with processing like bounds.=C2= =A0=20 It would also restrict the bounds to 0-256.=C2=A0 I would think the -a wi= th=20 no -i mode would be more useful for picking out specific characters out=20 of a string param of desired characters rather than using the raw ascii=20 codes.=C2=A0 I saw raw mode more as passing binary data to a pipe or file= . > > Tests and a completion function would be useful Trying to think how to design tests when the output is different every=20 time by design.=C2=A0 And I can't think what a completion function would=20 complete.=C2=A0 It's not like it's using long options or enumerated argum= ents. > > > 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 i= t for > myself. Maybe add something like '(in bytes or, with -i, number of inte= ger > elements)'? > > I also agree with Bart that it makes sense to put -L before -U. Makes s= ense to > alphabetise option lists in general imo, though this wouldn't be the fi= rst > 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 b= e 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 = can'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 = random > /* 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 I thought I got all the ones in code.=C2=A0 I wasn't sure enough about YO= DL=20 to remove them in that file. > > Lots of random double-spaces all over > > Inconsistent white space around operators, commas, e.g.: My normal coding style rarely uses unnecessary white space to save line=20 width.=C2=A0 It's not surprising I reverted to form a few times and didn'= t=20 catch it on review. > > 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 = should > be tabs (Ctrl+F eight spaces) I used editconfig, but when I had to re-indent the line I typed spaces.=C2= =A0=20 It still seems weird that the dev guide specifies mixing the two. > > 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 >