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 18929 invoked from network); 22 Nov 2022 19:48:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Nov 2022 19:48:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1669146536; b=cQrMAxhEdRIV78iAschSE24Z902cxQ7TRHVMr4kO6sGuY9KMgSrvGDT+mT/796YjlRoJJ2j2mu 6QOJylZR8Q8i7I4n31ckK86anE9OcnvXb6reORIJntaZg3aIOcsEWTtT9i1BAEAkXMdgUm+3m/ E04ZHIsnVfkOmdIrR6oFSrUp5YWb8gXHzPbjiRJx8mmZ/KdBjE4ZjboCIkU7L9/DKtBZEFxmpT yLYWpDm2Vx0H7j2MQ+mO9y/mhM4WuP4fyEhMDjWkD1ybqowb+5B3MjOPBi3BqQzPqJgSjhF6Gp jqHfmVVlHWwWQ41l2yYEIzZiucnTYytomqBDMPkfoQvqAg==; 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=1669146536; bh=SzKat869nPVuidDH2/+KvrlIpXl6dpM1eqpbdHlvSjw=; 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=pmYFH/xOq1oimJ953rVlEypDcm/uBubaRLpnMbNcMdlDJ4NaGV/StC1ymB+GkclKQyUXdkXNKf hzn9J40gM4Rt2yJfsRMQ9zYbGc9gFeXh5TWytuTrBk6vAKFfSZ3icdkPmzzv30s9IGC2gArpsn 76Wiw/G8I49WRHfwX3eps6IVsV9j+GMKzsQY6m0KY6XNVN3aVWtZqHMPfd9fha+oiEA04J1Nyp FgI/Jj3GbkTb2fT0kgiGZ6ORGpQslbwkuP6NRkUCJpURGzWdYQu3MEJD+pRGaPIaQJ5a4dvvaS SD1W6ouieoNdui7WfSs6qMmkbgp2056Sqvac5/P4mQcqww==; 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=SzKat869nPVuidDH2/+KvrlIpXl6dpM1eqpbdHlvSjw=; b=bdvE2+pogaJP2sTgL6LQ03nyAL iGzEK4EqqeNbdFEsiaSPHlMRrhFjIFlfLx52T0Jd/vv8az30V+qvlGWTmwv3KwxzqbvSe11LdH/0M nEdhntJYXqD6yPF8Jp+fvlx5QJPH3QC28uOq44Mq4VYo/9gz2Ih2a/12qs9PPZpdl7CPxmGUXZFAs nJDQ2sHQKGprellCRy8NuJ/7acUVgYrE+xpd+sBC6ApkA0pk3Z9MmzHZH/2YN7X6feJeptAlaaNt7 b1eWVZvH50QhDcqIE0EGuXIExygH021paOat68KVzWdkJ6GFH+6LsjUd01w5GQqmS6AzrCKMXor7M 1PaPlMIA==; Received: by zero.zsh.org with local id 1oxZGJ-0006Ra-R9; Tue, 22 Nov 2022 19:48:55 +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]:40224) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1oxZG0-00066h-DF; Tue, 22 Nov 2022 19:48:37 +0000 Received: from iris.zentaur.org (localhost [127.0.0.1]) by iris.zentaur.org (Postfix) with ESMTP id 4NGvvQ6JJjz3wZj for ; Tue, 22 Nov 2022 19:48:34 +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=1669146514; x=1669150115; bh=SzKat869nPVuidDH2/+KvrlIpXl6dpM1 eqpbdHlvSjw=; b=abRvdyHWoYEwn+qZcYSNOEW4N0xDEvwSWARMScU1jce0mvge 8uh6IpkNNS6Dql5aXnDint0ClBhyvV41PsBNoEX7T8mTcPFT4lGPHoccaPwX01NY zGhBBfolSO9CuEruA2hCbAN8xavBRYtAJatc2xSNrI1lsl1nbPyKy1D8Bj4BL5Ea FqC4u7ynbK4E2/7xEIzXo3w0urqbgAPseBZIVLDj4VgttNbTR2JTqbqj556Cjt1x 997HlhPqNA2qNjCREKxAaUXuwyVhFU+Tyaarg7JyTvMt4mAo4aC+hko6XepQl6Go 8wGNrDdlzbQV9JwZ86ATrbFBl18c1btJO5IX4g== 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 5W_3T4v7kzo2 for ; Tue, 22 Nov 2022 19:48:34 +0000 (UTC) Received: from [10.251.9.101] (rrcs-24-173-95-34.sw.biz.rr.com [24.173.95.34]) by iris.zentaur.org (Postfix) with ESMTPSA id 4NGvvQ0nQWz3wZb for ; Tue, 22 Nov 2022 19:48:34 +0000 (UTC) Message-ID: <044fe1d3-e353-3830-f2cc-2c0580892dc2@zentaur.org> Date: Tue, 22 Nov 2022 13:48:33 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] zsh/random module [UPDATED] Content-Language: en-US To: zsh-workers@zsh.org 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> <3423b634-a7c3-9efc-92cd-b9b995ac1c27@zentaur.org> <30a7e749-7f30-ecae-6479-a345b1682e7f@zentaur.org> <58053-1669139059.235596@kmQr.TTfz.Qbdo> From: Clinton Bunch In-Reply-To: <58053-1669139059.235596@kmQr.TTfz.Qbdo> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Seq: 51026 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: I On 11/22/2022 11:44 AM, Oliver Kiddle wrote: > Firstly, thanks for your work on this Clinton and for being patient wit= h us. > > Bart Schaefer wrote: >> Actually this could be done with -ap for SRANDOM and -af for zrandom, >> as well, but they're much simpler and the only reasonable quibble >> might be with the name "zrandom". > Bash appears to have an SRANDOM and if this is compatible with that the= n > I'd see no issue with having that feature autoload the module. > > The builtin's option letter API looks good to me. based on feedback, more and more I'm thinking the default action,=20 instead of returning a hex-string of 8 bytes should return the=20 equivalent of echo $SRANDOM. -c would always default to 1 even when=20 using -r, and -i would be removed and become the default functionality=20 as saving an array of decimal byte values could be achieved with -U 255=20 and -c. > > If we're going to quibble about naming, many of our modules use 'z' > prefixes on their builtins so I'd favour zrandom for the builtin too. > The use of "get" and "set" in naming is often superfluous and "get" > implies the fetching of something that already exists rather than > of something that needs to be created. I thought it would be confusing to have both named zrandom, but I'm not=20 opposed to the idea. > What issue do you see with "zrandom" on the math function? Most of the > existing math functions correspond fairly closely to libc counterparts. > Distinguishing it from those seems reasonable. > > The question of why $RANDOM isn't backed by some secure modern and fanc= y > implementation seems to come up roughly yearly. It's not a feature I us= e > especially often and I certainly don't care, either about stability or > security, on the rare occasion I use *(oe:REPLY=3D\$RANDOM:) to shuffle > a few mp3 files when playing them. Neither would I have any special > attachment to the existing $RANDOM implementation if it was changed in = a > compatible way. > > Given that it can be autoloaded, could we move $RANDOM to the module > too? I suppose we could move RANDOM and use rand_r to try to keep the=20 documented behavior, though currently the behavior is not consistent. I tried changing the other places zsh uses rand to use rand_r and found=20 that on at least EL8 the use of rand48 screwed up the sequence even when=20 using rand_r for RANDOM.=C2=A0 I'm guessing glibc uses the same engine fo= r=20 rand_r and erand48 and doesn't reset the upper 16 bits when rand_r is=20 called after erand48, but I haven't dug into the code. I'd rather make RANDOM a 15-bit integer sampled from the same source as=20 SRANDOM, but it would mean completely breaking an only partially broken=20 documented behavior. > > Oliver >