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 8223 invoked from network); 4 Nov 2022 07:29:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Nov 2022 07:29:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1667546941; b=k7fvv4eK1/o//k7ICjv78Ya11eYChoClC+YcI1ugbpPAiLWoOZ/YD5SxxRuklrQPU69iZC41nD OfK2Bn62aycAvozIuUxLBOiSSpywhdoYnC7DZvmex0+46e9q1dZlSkImuTYouNAMnw4ex/rDyO BQFD2ucfgznsEFWbDLjXEGSovfu3o08kejclDFPHUZsiSG3SepRvE/YIcjK1YHXxDL+7VU1YiK 9aEziRlYgaslNePiqlNY/MOwOi+4psPy3teRV3p1bFGws9RxRZs5CTFGw2mX5GVRJNMPKnyfEk vS4UeS1eZ67eCRTfoAGDWQiI91LV+3zyippGLqinL/bsQQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.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=1667546941; bh=DeF2xhWmcQtCGjyS+NtjiSO+RAH1rUoAlu/PH9BpdsM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Subject:Cc:To:From:Date:References:In-Reply-To: Message-ID:MIME-Version:DKIM-Signature:DKIM-Signature:DKIM-Signature; b=lgD6dbjB74QqUBaWvlknna2cENvH8KPGboJBFjwTMUX9KhvNawZN7YKu1h0waQ58I7/TP/PGDE 0HIzZLra6oBzfSJqhUnadZczMVZ6j1naiz+Bx66miVIEGsRFem2ifGCkMPoeSaWWYfS8XcU1CN lrInVECqyuTetghpm12EhtUI1s89NeRk77w2LyRcaqha0jZaJ1qvfZj+32pndU4/myk9T1ir6Q 6TV/uVmxoitKD9uhac2fsIgS8no7s1XIUkdUFTnlvhymxIkXtnntGrGdJGYRUNid/mI4C4MaRb h+5PbaU8/CIOnMopZimn+Fs7ECqmXfDliyfcn2rinpHxEg==; 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-Type:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=uREqO8UPmyEP2nTMyI1YVqAPnzRJB9m12c24mTz8ysU=; b=KOBzu/2pbW9cFTOWpUZL/W5M8R fWcYJsTsLmtuvNInGCjz8pinKYrCyCIJSj/7ncgv8AQ0AhcammzX4/qxFNH55V83qvqvny2S7cQ3u 0ZS0w2rM22gc8221JghWrHCUyqFW1mcLs/hbjmFazffaw7IFmBHDgsGrKj170Pkwz+PqTes83LVky KvEgGNra/qSuNZ4DNLTlT9hZI4Ft7LnGEcI+LjzpeZevMeUqTXp/YKIQ2DMeHf8bTidYo8tN96AHk B+jffflUyKHzNDKeNiyfj1IHj4K4bgrZEoB3709Q6nFUUpUKXajg+RehSGTRG20M9r7ZwOuY2Juu5 RGDtSJbA==; Received: by zero.zsh.org with local id 1oqr8O-000BLY-MF; Fri, 04 Nov 2022 07:29:00 +0000 Authentication-Results: zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.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 out1-smtp.messagingengine.com ([66.111.4.25]:47691) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oqr85-000B1U-QT; Fri, 04 Nov 2022 07:28:43 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 95FF75C00BA; Fri, 4 Nov 2022 03:28:37 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute5.internal (MEProxy); Fri, 04 Nov 2022 03:28:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana.is; h=cc:cc :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=1667546917; x=1667633317; bh=uREqO8UPmy EP2nTMyI1YVqAPnzRJB9m12c24mTz8ysU=; b=blq7BGKmAxoITMNRLjERwRIgDD LEr9JhNTHqqH70k0wDjk5lUKvwkkAX1GgyZYQvhDGOhpatPO4mkK0VIFXf7cCYze 6OOxPuonmLe+8w0G+nsU5pdTejKrXNM1tR/0gb3TjR2V+XnXvd64CaeDwi06mr1m oD3/mLMUodZKd2kaZYLVPuNJhXah0eJV84MQENfuxXCntJW1oN/pmNSRYlpTjUMX 3zomINqhNhy2iLlRatHluO5uc7j6mLpO9/Oh0QpiWqsw/BPS9P/Hb5IxRfNXY5o/ ANeRn1MuRMxtx0I4ETbW/zynUa1HeBkaX0feXDfLYSPT76vT0VUFil2N5buw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=1667546917; x=1667633317; bh=uREqO8UPmyEP2nTMyI1YVqAPnzRJ B9m12c24mTz8ysU=; b=MyYTzgyJD5kYjtrB64o6vFdJpQ+MfstGWw2RQ2m2oUD/ OujkVf8Ir/9P0C0acvmI0rqNQyMacjiZq4BJYVs0vpmaXOczzKeMCXWq7WabybMv 3fPzzpnjMe0ZrQtns6MWdmxinu0JrOaONP2XARFwBM3R1Z+KeDoZpa+fV/qufqXg VChr+LRf1VCTPVzDtkEqzSzQvIbcKZw/lt83YLAP93zoRnxWxHagCq0P2Pv44kwb vOc4fxHO64cFardOcQ/6oKzjYoIEOHrHWmHhwqQpoqqqZQ5sR9K+D6v5a6kI0rKN yvK9dg2DrjlUlxbYtkjiJLHLEGEMLBmlM/EzSCE3bQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvddtgddutdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvvefutgesth dtredtreertdenucfhrhhomhepuggrnhgruceouggrnhgrsegurghnrgdrihhsqeenucgg tffrrghtthgvrhhnpefggfeifeetueeutdeitddttdfggedtleevjeelgfekteekhfekgf dtgeefueelueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegurghnrgesuggrnhgrrdhish X-ME-Proxy: Feedback-ID: i9be146f9:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5AA9B1700089; Fri, 4 Nov 2022 03:28:37 -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: <41205a86-8aad-4821-baa4-1d2ac9bf3c5d@app.fastmail.com> In-Reply-To: <1e8ea669-7a25-b321-6024-72dbc43ac023@zentaur.org> References: <741b77be-b679-76cc-f8ec-49c9d89323c1@zentaur.org> <1e8ea669-7a25-b321-6024-72dbc43ac023@zentaur.org> Date: Fri, 04 Nov 2022 02:27:22 -0500 From: dana To: "Clinton Bunch" Cc: "Zsh hackers list" Subject: Re: [PATCH] zsh/random module Content-Type: text/plain X-Seq: 50864 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 Fri 4 Nov 2022, at 01:22, Clinton Bunch wrote: > Then why would you use the builtin in preference to the parameter SRANDOM? I guess the main reason would be for the bounds functionality On Fri 4 Nov 2022, at 01:22, Clinton Bunch wrote: > Copied that pattern straight out of Src/Modules/datetime.c TIL. I also lied about sysread, it does the same. print/printf, zparseopts, and zstyle don't. Can't think of anything else off the top of my head rn On Fri 4 Nov 2022, at 01:22, Clinton Bunch wrote: > Trying to think how to design tests when the output is different every > time by design. If nothing else it could just make sure it's in the expected format On Fri 4 Nov 2022, at 01:22, Clinton Bunch wrote: > And I can't think what a completion function would > complete. It's not like it's using long options or enumerated arguments. Most of zsh's built-ins have no long options but they still have completion functions. Some people use completion as a substitute for the documentation. Attached _getrandom for your consideration (assumes no further changes, tested very minimally) btw, in writing that function i realised a few things: * In the documentation, i think the default upper bound should be 4294967295 rather than 4294967296 * Why is the maximum length 64? Also, should that value be documented? * If you put -i after -L/-U it overrides their effect. Maybe the `if (integer_out)` in the code should be an `else if` instead? * It appears that -L is inclusive but -U is exclusive. e.g. if you do `getrandom -l1 -L2 -U3` it will only ever return 2. I assume that's not intentional? On Fri 4 Nov 2022, at 01:22, Clinton Bunch wrote: > It still seems weird that the dev guide specifies mixing the two. I agree dana diff --git a/Completion/Zsh/Command/_getrandom b/Completion/Zsh/Command/_getrandom new file mode 100644 index 000000000..3513e10b7 --- /dev/null +++ b/Completion/Zsh/Command/_getrandom @@ -0,0 +1,12 @@ +#compdef getrandom + +local min=0 max=$(( 2 ** 32 - 1 )) + +_arguments -s -S : \ + '(-r -s)-a+[assign result to specified array parameter]:array parameter:_parameters -g "*array*~*readonly*"' \ + '(-a)-s+[assign result to specified scalar parameter]:scalar parameter:_parameters -g "*(integer|scalar)*~*readonly*"' \ + '(-r)-i[produce random data as 32-bit unsigned integers]' \ + '-l+[specify length of data]: :_numbers -d8 -l1 -m64 -u "bytes or integer elements" "data length"' \ + '(-i -L -U)-r[produce random data as raw bytes]' \ + '(-r)-L+[specify integer lower bound (implies -i)]: :_numbers -d$min -l$min -m$max "integer lower bound"' \ + '(-r)-U+[specify integer upper bound (implies -i)]: :_numbers -d$max -l$min -m$max "integer upper bound"'