From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, MALFORMED_FREEMAIL,MISSING_HEADERS,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 6F9D02555E for ; Tue, 7 May 2024 01:28:50 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1715038130; b=NxMK8asszPbaPh31kXxVVK4/0TPRenZyy01A6+iOOwjikedb+MnR6kapqQYi9nbzDKcQjRuu6Z qIZxf/uIsY/lugxdvwZJOT6CNhfFMF5gdZ80S9GO41wnwxv9QcH0nlTxdD6depbx7QoPO3pWzn YiDFtCWGYxbX45PIb1jugA5hcvt+szSPkKVKcvgnzyy/1VrcT/2h4V/ZoKYTWI7VB/rjdkjhxQ O5THARGKAWCh/P73tl7NAK4XiDkd+3ykLSmrJ9eZ4x5Kbv5uANsVDLmxtjB5VYU/rnDXydVEUw C9ov86KduEAtc0rROXzttWRSQLA4RPDrcdNiuK3Acg2RDg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f182.google.com) smtp.remote-ip=209.85.208.182; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1715038130; bh=ZEXhP+3pA6M4rRwttbWeNB+/ICH2uEiOMgx5eXctNHQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=Iz6mPD/I2SBdL+HLNutYYUa9BHvnSeHHF6HrCN/tXlWSiodorxv2uyHLzkiRLv186Er9JgeqlG Q2xtCLP29x8m3rNdqD83t+qJjL7AFT2BvmN7fjGTv80TE7oIfjhPL/E5kDSeNQhTe2/o6clGly 05oUXmBEZfaCnUuCgPxTQegdJ2JhBVrvtLRCCBAvneHMNYBuUY3Q8hIEEM8Acs+VcRPL+asj0d LeYBNQk/KZFPaDOy9q5n/EAH8LAHbY/lF21F8higpSeSCWmA9ZvpYLzZlvq6vnEaoNHoBpqxcf ST2jnsqK0RvtKomiE8YQ5n7TXcZiW7wsc0aeqM9HnyPgyw==; 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:Cc:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=vRopAtvxFR4ALLjy+/YypwWLSkbfogZ4DEvGk1/KXS4=; b=rb5mGPwXKspizXw08RTXqE05ba LfsC3imKNxw+UeefaNIL9QsiF4vB3gEeTVQCGSFWywK5gutzONwq9ea7vF04SS+d1WfpVbOc3Ysvh b+mi4vYhw1dgKs6nTxCaoropk0d7Sk3wy6f530R7CcQsMEDt5bwsB7SGRscql/HomhSOOqqX07T5m EcVaTNLN2EvTI+FNq1B0XFBOn8ZbG5UhIsJPZUN8CMQ4MIrM8cZOGuV6BTYxXpFh41DVBdIJe//0P gcLO+3Zow77ZLWveRALhUQbVVmZsRx419mUe6tnsZEx09aweZ4+a0D6dz7VOx0NPjskS3dBnWaQEG x55VYd+Q==; Received: by zero.zsh.org with local id 1s47lK-000JSI-EA; Mon, 06 May 2024 23:28:50 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f182.google.com) smtp.remote-ip=209.85.208.182; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f182.google.com ([209.85.208.182]:49292) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1s47kj-000Ijf-Sx; Mon, 06 May 2024 23:28:14 +0000 Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2e38a7ebdb6so14292411fa.2 for ; Mon, 06 May 2024 16:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715038092; x=1715642892; darn=zsh.org; h=cc:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=vRopAtvxFR4ALLjy+/YypwWLSkbfogZ4DEvGk1/KXS4=; b=SQfqtYvy3tbhsca2hfezuA7hhRHTlmAIrcYM+jijH8tGFoLr3zU/oml99KWZvU1ELu MFVY3kxsxvSy046trGwv2oEzLu6SFN6ycFNTyW/Tdzk6unPG9OUGjDs8YadNTGLzjG0U MYNJIooTTmYsmmA/3z9GJZhr8L3VL+RSJtBJtnZxgwOLvlD+o1pyIsSlK9UaTJdGNiGI 3lhAvpo/+siXJQaNJZZ19sJ1dGmTt2e1d3cy8NhTeyWO54F7BNcXRZ/Vuz1/JosVkF6A Mw0wP7bav9sRTHR+Xshl+87k3uDNCIjDLx8VoIG2gcQyQx4Nl6Xs0oUYLIoZ+RqQ/Qzb 3xSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715038092; x=1715642892; h=cc:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vRopAtvxFR4ALLjy+/YypwWLSkbfogZ4DEvGk1/KXS4=; b=ozSR5FBuoF2YV1x1JwuMRtPtaAc3WJmJhQl4hE2v/IZpap45fSGkWD7CC6Xa6v+fum 3nDrgoDHgRyts+ZNKjdO94f2gDgtZUiX8YjhmwcaCEACF7gBgnmlV57TbejsViWwuRV6 9daniVk/3CUbl+Z7guHnDS2k+fVNqJFInpRpvnVpZILXf5swtMgvIaVTxvNcSWuvFX3Q 1BETClg20yxIomizQg0D/PtDsQbZEpDo1hpT0SJRMbGXHkfjtE/JXeGxjzoKuXskjf/q 6/Pg5Xh89mbJNCBySkFdpq+wpSgMxztloz3KsMdyQbCjZlQRzUYpozOGIe0oBAAXTsbO vMGA== X-Gm-Message-State: AOJu0YxKI+6oE1V9Ydl08RO99EP7Hj1nKOYBk0zWAbtXN4emBz68fQ4R xvq3b5GEuTS64eebCd8d6xs4Dqf5Blub7aObcA5c+kwS7sC6sePz4VUrJrc354ittFFYDIvWIvz 8VPjYb+Fx40FL77JKQTAiJyHtSV2VXA== X-Google-Smtp-Source: AGHT+IE7U8VYRxhbd+GjKHABBQiuC/WkoHvDnIOtHgwV17augYAXhSOAKJ/UHPiNhEaw4Cks5VGy2KJbySQ4gXzpoL4= X-Received: by 2002:a2e:2414:0:b0:2e3:603e:4697 with SMTP id k20-20020a2e2414000000b002e3603e4697mr2535289ljk.36.1715038092196; Mon, 06 May 2024 16:28:12 -0700 (PDT) MIME-Version: 1.0 References: <8809e9e7-2389-4bb7-ba67-95222d302594@eastlink.ca> <9022e6cd-74a0-4438-a858-c0cf2f747d8e@eastlink.ca> In-Reply-To: <9022e6cd-74a0-4438-a858-c0cf2f747d8e@eastlink.ca> From: "Mark J. Reed" Date: Mon, 6 May 2024 19:28:00 -0400 Message-ID: Subject: Re: create variable with calculated number of spaces. Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="0000000000004302980617d16c10" X-Seq: 29917 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000004302980617d16c10 Content-Type: text/plain; charset="UTF-8" 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 On Mon, May 6, 2024 at 19:04 Ray Andrews 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. > > > --0000000000004302980617d16c10 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The printf command is built into zsh. I&= #39;m not sure what makes it "fancy" or non-native.=C2=A0

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

Mark J. Reed &= lt;markjreed@gmail= .com>


On Mon, May 6, 2024 = at 19:04 Ray Andrews <rayandrews@eastlink.ca> wrote:


On 2024-05-06 15:38, Mark J. Reed wrote:
> or, more efficiently:
>
> =C2=A0 =C2=A0 printf -v spacer "%${diff}s" ''
Nice and compact.=C2=A0 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.=C2=A0 Legit?=C2=A0 Or= false
frugality?=C2=A0 What I half-remember is some loop that has an iteration counter.=C2=A0 Mind, there was one of Roman's speed tests where he used= an
external command and had a huge performance improvement, so thereyago.


--0000000000004302980617d16c10--