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 26405 invoked from network); 24 Nov 2022 16:20:41 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Nov 2022 16:20:41 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1669306841; b=ACTNIKJ9Hl7yaidso4uiqHglqUbl4bloRIeai4LnJXgiBEzphD1+yqbgFhzqfAXjppPu7ZnWVX Zwmi2XoqXbKbX5L59bN1VnPcDSzYx19Z7vcIrXuUA5OmruV3lPLWeq7Z3LfdkutLmMcjTWVPxO 6pWkEBx4WzY+jlSKzk9uxr2yq7qFGHJPJS7U1ZUqCRuK+yjkXs5F6r3sQqOgVurbrXPR+W+jvR 0+a5lJctU3430zs5y98fEZO1Z5cCMH5mFwH8X3DNo8fyYSe8BN97SmSmmlL82X8H3l1F/2IbbH 8o4bfxh6nUOIifl9Nu3DQBol2/G5snzYHS5RVgzggqPn3Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1669306841; bh=hAfZX2XqVEt7qfaNUtR5pBhe5n0f7gxzqoPYSbZ+vGk=; 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; b=oEjhOddRIWjt0XbTn4wgwWF/BERsgUYopXV0tFesfGoF7ZOjm/xy41vVmOyrHjAs4VpWPWHPVb rttKT8VeitbclpJr0VfsN9zcXd6twTGBaSjsXvZ/Q8+zr+owTaaK7zbutf63djCN67PXYmp/Vr hOwHrKVeduBd+RK8jvMF09LB69dNbtrJIOcjTFwZ1UJxCc//+6ETLEZBFcCpKwxAl4zvhi28yR gDE0pGpZ7Q0JmrzyI82U+5OL0h9hVDtP87NyhLJUEGcuBrqsjdBVI6IZe4RcxcqGk52wlim8l5 mzxgYCZ9xZrJsonmqW2fdAqCL7MUg6qBqSLpaz1DsfLGOw==; 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=hfLkgDWgDXUCGXJXZcBeG7KW5lpAgfZjg0/XllX6TpA=; b=DE9fr2eLe8oAHnxjahEP1jBh99 0pjNz+Alz/arQvKatwlwz3A/9ZZDDAE3em/ejd2ZQZMdoPFlp0aMPv+hiK1N7iPb4CEQ1KZTz72ls 7WeC+sKE+TriD0n2gVC+/2Hg4th8/7QF4wq/ocfVgi14To8RgemXtjcALapxH2Tyh3Fe1e4/HOf4Z OiWUbXERRWNHoO+tita/7pZatbYKUkMjGZi8hzf5pMw65VHxpuOzoTJp1Vwqre9DRF5iFkufp/y6o y3toBXDlXSqoPe00JI2GgoQsnFyjuAC3OaZuS0kyHgq7xTe0sSZE842KmSdrW9lthIhvKR36LYp6A wua/WVFQ==; Received: by zero.zsh.org with local id 1oyExs-000FMW-2t; Thu, 24 Nov 2022 16:20:40 +0000 Authentication-Results: zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none Received: from relay6-d.mail.gandi.net ([217.70.183.198]:38023) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1oyExF-000F1U-ER; Thu, 24 Nov 2022 16:20:02 +0000 Received: (Authenticated sender: stephane@chazelas.org) by mail.gandi.net (Postfix) with ESMTPSA id BBB56C0006; Thu, 24 Nov 2022 16:19:59 +0000 (UTC) Date: Thu, 24 Nov 2022 16:19:58 +0000 From: Stephane Chazelas To: Daniel Shahaf Cc: Clinton Bunch , zsh-workers@zsh.org Subject: Re: [PATCH] zsh/random module [UPDATED] Message-ID: <20221124161958.jh3xlzq7hiyw6vut@chazelas.org> Mail-Followup-To: Daniel Shahaf , Clinton Bunch , zsh-workers@zsh.org References: <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> <20221123195222.GO27622@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221123195222.GO27622@tarpaulin.shahaf.local2> X-Seq: 51064 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: 2022-11-23 19:52:22 +0000, Daniel Shahaf: [...] > > > 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 :) You'd then need a separate option for length/padding/truncating of those numbers and maybe even an endianness one. For instance, without -i, at the moment, you get 0-padding of the numbers to length 2. I'd expect with -i -f hex, you'd want either 0xabcde or 000ABCDE. With -f raw -L -12 -U 1234, you'd want to specify if it's short/int/long you want dumped, etc. To me, having $SRANDOM added to core zsh, and maybe a randint(first, last) added to zsh/math would be more than enough. To get a stream of random bytes, /dev/urandom is best. and we have read/sysread to get that. We have printf / print -f for formatting numbers already. As already said, having some equivalent of perl's pack/unpack to interpret/generate binary data would be more useful than adding that functionality to every new builtin that deals with some form of binary data. -- Stephane