From: Stephane Chazelas <stephane@chazelas.org>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Clinton Bunch <cdbunch@zentaur.org>, zsh-workers@zsh.org
Subject: Re: [PATCH] zsh/random module [UPDATED]
Date: Thu, 24 Nov 2022 16:19:58 +0000 [thread overview]
Message-ID: <20221124161958.jh3xlzq7hiyw6vut@chazelas.org> (raw)
In-Reply-To: <20221123195222.GO27622@tarpaulin.shahaf.local2>
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
next prev parent reply other threads:[~2022-11-24 16:20 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 17:13 [PATCH] zsh/random module Clinton Bunch
2022-11-03 17:50 ` Bart Schaefer
2022-11-04 3:17 ` dana
2022-11-04 6:22 ` Clinton Bunch
2022-11-04 7:27 ` dana
2022-11-04 12:57 ` Clinton Bunch
2022-11-08 0:18 ` [PATCH] zsh/random module [UPDATED] Clinton Bunch
2022-11-18 14:30 ` Clinton Bunch
2022-11-19 6:42 ` Lawrence Velázquez
2022-11-18 16:23 ` Stephane Chazelas
2022-11-18 17:08 ` Clinton Bunch
2022-11-18 18:12 ` Stephane Chazelas
2022-11-18 18:38 ` Clinton Bunch
2022-11-23 19:52 ` Daniel Shahaf
2022-11-24 16:19 ` Stephane Chazelas [this message]
2022-11-24 16:30 ` Roman Perepelitsa
2022-11-24 22:39 ` Clinton Bunch
2022-11-25 8:53 ` Stephane Chazelas
2022-11-25 9:40 ` Stephane Chazelas
2022-11-28 16:37 ` further discussion of zsh/random (was [PATCH] zsh/random module [UPDATED]) Clinton Bunch
2022-11-21 1:07 ` [PATCH] zsh/random module [UPDATED] Matthew Martin
2022-11-21 1:59 ` Clinton Bunch
2022-11-21 2:21 ` Matthew Martin
2022-11-21 2:57 ` Clinton Bunch
2022-11-21 3:14 ` Lawrence Velázquez
2022-11-21 4:17 ` Bart Schaefer
2022-11-21 5:05 ` Clinton Bunch
2022-11-22 13:42 ` dana
2022-11-23 19:49 ` Daniel Shahaf
2022-11-22 17:44 ` Oliver Kiddle
2022-11-22 19:48 ` Clinton Bunch
2022-11-23 1:23 ` Matthew Martin
2022-11-23 2:58 ` Clinton Bunch
2022-11-23 4:14 ` Matthew Martin
2022-11-23 13:41 ` Clinton Bunch
2022-11-23 20:33 ` Daniel Shahaf
2022-11-23 21:42 ` dana
2022-11-23 23:54 ` Daniel Shahaf
2022-11-24 0:17 ` Daniel Shahaf
2022-11-24 1:05 ` dana
2022-11-24 13:52 ` Clinton Bunch
2022-11-23 19:46 ` Daniel Shahaf
2022-11-24 2:58 ` Clinton Bunch
2022-11-24 10:07 ` nimaje+zml
2022-11-24 13:19 ` Clinton Bunch
2022-11-24 14:33 ` Clinton Bunch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221124161958.jh3xlzq7hiyw6vut@chazelas.org \
--to=stephane@chazelas.org \
--cc=cdbunch@zentaur.org \
--cc=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).