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

Re: create variable with calculated number of spaces.



The printf command is built into zsh. I'm not sure what makes it "fancy" or non-native. 

(Of the three printing commands it's also the one that works the same across bash, ksh, and zsh, but that's not a concern if you're writing a specifically zsh script.)

Mark J. Reed <markjreed@xxxxxxxxx>


On Mon, May 6, 2024 at 19:04 Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:


On 2024-05-06 15:38, Mark J. Reed wrote:
> or, more efficiently:
>
>     printf -v spacer "%${diff}s" ''
Nice and compact.  One thing tho, I'm not sure this is the correct way
to think, but I have an instinct to stay away from 'fancy' commands like
printf and to rely on native zsh code where possible.  Legit?  Or false
frugality?  What I half-remember is some loop that has an iteration
counter.  Mind, there was one of Roman's speed tests where he used an
external command and had a huge performance improvement, so thereyago.




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