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

Re: The elements of enlightenment



On Mon, Dec 5, 2022 at 10:21 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> On 2022-12-05 11:58, Roman Perepelitsa wrote:
> >
> > Neither printf nor setopt are heavy. Forks are extremely inefficient
> > though.
>
> ... and '$( ... )' is a fork? [...] it spawns another shell, yes?

It invokes fork(2). See `man fork`.

> I like efficiency in principle even if in practice it's miliseconds.

That's why I tried to quantify it in related terms: on my machine
executing that thing 100 times takes over a second.

    % time ( repeat 100 var=$(printf hello) )
    user=0.00s system=1.06s cpu=90% total=1.178

> I have to keep appending to the list for each line, can the 'print -v
> var' method handle that?

See `run-help printf` to see what `printf -v` does.

Roman.




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