Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: use of rand() in zsh



> On 11/10/2022 15:15 Clinton Bunch <cdbunch@xxxxxxxxxxx> wrote:
> 
>  
> On 10/11/2022 8:23 AM, Peter Stephenson wrote:
> >> On 11/10/2022 13:51 Clinton Bunch <cdb_zsh@xxxxxxxxxxx> wrote:
> >>
> >> 3. Write a module (e.g. zsh/random) that introduced a new special
> >> parameter when loaded (more complicated, but isolated to those who want
> >> it and possible to fail on systems that don't have a kernel entropy pool)
> > An autoloadable parameter gives you something that works basically as if
> > it's part of the shell but can be turned off as well as giving an error
> > if the module isn't available, so might be the best bet.  So the
> > .mdd file would have
> >
> > autofeatures=p:SRANDOM
> >
> > pws
> >
> That's a neat trick, but as someone who has had to hack to build 
> software built and primarily tested on Linux, on a Unix system stuck in 
> the '00's (if not the last century), I'd rather have an explicit 
> load/test for the existence of the module than have it blow up on a 
> system where SRANDOM didn't work. (8 years as an HP-UX admin)
> 
> My $.02 for whatever that's worth. :)

You can do that too: the autoload only triggers if you refer to
$SRANDOM first, at which point the module will fail to load ---
quite possibly in an inconvenient location.  But if you write
your code to do the load explicitly it will check at that point.
So you should have the best of all worlds.

pws




Messages sorted by: Reverse Date, Date, Thread, Author