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=-3.2 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, 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 C377E20CE9 for ; Tue, 7 May 2024 00:39:36 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1715035176; b=ZI3zv9A6FeSnSqzxPtvkbCSC08iaasdxVTlEOcOQi216RQpbYidt3dwhPYZ4lRfS079eCPM2Md gigzhjOAB898xV9xF49bOvtBatLOct+IeTrZL5pFncP/TTTB7PbNijJNnCC7IOh9eDAGUZw3s4 jzvqOX7/ivAoOBz87F5iA+Vef+xF9ajw7Sl/d+TUD6lgiIHEfPXqZNzHnoe4iDrcCDSUgCj7hl di41rowwlCZumuNiTNGrkL4uS0nZJ8tFB+Plw10/bjUw/9oDoj0ytJKYZ/l/NOEjV27IWWwuAb l0JppkT9N140x4Bp5by0yJoYI3k/ZGU/2wDxpaKGNE2+Iw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f172.google.com) smtp.remote-ip=209.85.208.172; 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=1715035176; bh=NnvG+A/1y4g7rP5LgrbTyDxnEDrLMf4CaTW+zO2mOvc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=ObDU/2wsxXWEIta4iQ9GXo3lrg825bD8yx3WnVDwnosbxHapCP7JoBXane4VgKQygm1KitmPse N0t0UYeeqhpoZPiu6Vc13pC9XXsUKArErOywxMSbmOv2ibHVKIkjpORwvMjyJLEFk1a7ZXE9/2 Edw8NAhnNrOff1yfSbT/MWP5CDYJQrRHGeTvj4Y151IyeCi1YAc3mBZX7RdKJZvda1HrdU+VaA HFKNF3UE0xqaZ6T4H82xrJ2w4ZvcIq4JR+ml7Bv9w5jbvuT8F1BOJPPpbhs98D2GUImAAcbUpm d9uK2FxLNgniRoZl2OKGwS3ZmNICgTypiF9feJFUVgRvWw==; 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:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=l/7VToRXj3rl+nsWxmlpswYwa1QHvbAKNDdpA6jrSWE=; b=JaA7ox4d897534adRR3djiVgT3 D8jDqVF/L+XA0xoH7rX4nCu58tLJqoQNqrev97i9vtacjFTij6rY70/nZOShxNfl2AispVFOx067F AYnxA66HBJOsagDUGZX7nH8Yy69Rk0rLW672rheEzxTXlrPRR2JXrYwX6Q9DzYk3mB8MTEisM45gM Vsc5hxBP3aXq8iM868tTRuQXIIdv2j6G8qhc6aQQewv3FSYgloQdcW9eydGBPJYWFWzaS0d08mOSO db4sswCV+JeubkfkiGzHdsbo7WFJkK8uMfiwPCd0OZqk7SNVKy7v31vP84dSev5LsDdv/qroXj5Vq /qlG/5PA==; Received: by zero.zsh.org with local id 1s46zg-000FsB-K1; Mon, 06 May 2024 22:39:36 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f172.google.com) smtp.remote-ip=209.85.208.172; 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-f172.google.com ([209.85.208.172]:60848) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1s46ym-000FAx-60; Mon, 06 May 2024 22:38:40 +0000 Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2e0a0cc5e83so24644301fa.1 for ; Mon, 06 May 2024 15:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715035119; x=1715639919; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=l/7VToRXj3rl+nsWxmlpswYwa1QHvbAKNDdpA6jrSWE=; b=W4AdadEe4BzUfZCE7+iJfXhnaLmHjKJYXRhs0d1XvH+lbQ3coC2x1Z8booW3CYtpza ROqCqq6yaGbNOBEc6UPoMNX1yrUUEzd8+Z3yKg2lcZBUZc0e1UrkWCjbHI0fWyh8qor9 T9sF907dQ/NelmlhJ6MDGPrcNwVh6sOhhpbNFJ89IBsSj6ngvbmtiOLstppylGbhI00u XQ3+KoqJpTixaLp37D4RXIs8dzaZvdHG6X8DcJabHJgRcg96HwdcPRqX9u+LpuhGJr2R MgaploqqVnGgSTVPhw0Q8KUFe3tP73TTJq8tCL95eN3LphRNv0V5f5/i8G9+l15Oi6ph Yn3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715035119; x=1715639919; h=to: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=l/7VToRXj3rl+nsWxmlpswYwa1QHvbAKNDdpA6jrSWE=; b=ofi7bPrzVKtYIiGUfYv/ZY9KozCwE6vVhNCUNiGXpFHgIUK/dbA//Qmp4ZWI88J9Bl neHiB+dCGjfUBCq9JqHWjUIX/A/l9yAAw6v2XjikX6q4HOZqMzCw2q7cDxBvffp3/Zmx ukVx5Ba24C6PG365KGm184DWdBbEL+iVeLizJbu6Kih7H9GkvzSzEXwcOYq4snn/mHIv vqzi0Xd20Kk+DpnDwZx0F9hKrveWXyzDYN4aHYDbWqCzRT4Gjwu5sMr36ZtboJ4hB05I VMZ9Up8n5fncqZI5LJQDq7MsVTF4IIMl7aqk6muXxqiwIeqkOjEkQ6TFuHD6zGJvrPI1 D9gw== X-Gm-Message-State: AOJu0Yz1QegcTJN7a81gyGDOexz4Bn6AndWcPw0zk9RkwtHPl8d2GZbl to9VmIMmMxYLLXwIMeYnqawysswwcJX+2TTEpFDqEZ05y/ehmrGbMKZWUQyigV/IXYGLG4ZVma2 ML3A29Qxzchys7cAQNSoswQfGTAfSpw== X-Google-Smtp-Source: AGHT+IGvnewIcTD5r8y/CWcqBKxJo36z0MJCwtNDwVpw9uqZP0sNxHq4OTKPQeQvBSxUphhmZXjGAgg5LwS2VZaXFn4= X-Received: by 2002:a05:651c:81d:b0:2d8:df61:9c6c with SMTP id r29-20020a05651c081d00b002d8df619c6cmr5351673ljb.20.1715035118658; Mon, 06 May 2024 15:38:38 -0700 (PDT) MIME-Version: 1.0 References: <8809e9e7-2389-4bb7-ba67-95222d302594@eastlink.ca> In-Reply-To: From: "Mark J. Reed" Date: Mon, 6 May 2024 18:38:26 -0400 Message-ID: Subject: Re: create variable with calculated number of spaces. To: Zsh Users Content-Type: multipart/alternative; boundary="000000000000066c510617d0bb5a" X-Seq: 29915 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: --000000000000066c510617d0bb5a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable or, more efficiently: printf -v spacer "%${diff}s" '' On Mon, May 6, 2024 at 6:35=E2=80=AFPM Mark J. Reed w= rote: > Well, mixed up your var names. This is what I meant: > > spacer=3D$(printf "%${diff}s" '') > > > On Mon, May 6, 2024 at 6:33=E2=80=AFPM Mark J. Reed = wrote: > >> printf "%${spacer}s" "" ? >> >> Mark J. Reed >> >> >> On Mon, May 6, 2024 at 18:04 Ray Andrews wrote: >> >>> So I want to adjust the length of string1. I do this by inserting a >>> spacer in string1 who's length is calculated from the length of string2= : >>> >>> local diff spacer >>> (( diff =3D $#string2 - 76 )) >>> for (( dd=3D1; dd>> ... # spacer will be incorporated into string1, not shown. >>> >>> It works fine, but I'll bet there's a less laborious way -- some way of >>> creating 'spacer' with 'diff' number of spaces without the for loop. = I >>> could make 'spacer' too long and then cut it at an index [diff], but I >>> doubt that's as simple as it could be. I know it's there, I just can't >>> quite remember. >>> >>> >>> > > -- > Mark J. Reed > --=20 Mark J. Reed --000000000000066c510617d0bb5a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
or, more efficiently:

=C2=A0 =C2=A0 printf -v spacer "%${diff}s" ''

On Mon, May 6, 2024 at 6:35=E2=80=AFPM Mark J. Reed <markjreed@gmail.com> wrote:
Well, mixe= d up your var names. This is what I meant:

=C2=A0 =C2=A0 spacer=3D$(printf "%${diff}s" ''= ;)


On Mon, May 6, 2024 at 6:33=E2=80=AFPM Mark J= . Reed <markjre= ed@gmail.com> wrote:
printf "%${spacer}s" "" ?=

Mark J. Reed <markjreed@gmail.com>


On M= on, May 6, 2024 at 18:04 Ray Andrews <rayandrews@eastlink.ca> wrote:
=20 =20 =20
So I want to adjust the length of string1. I do this=C2=A0 by inserting a spacer in string1 who's length is calculated from the length of string2:

=C2=A0=C2=A0=C2=A0 local diff spacer
=C2=A0=C2=A0 =C2=A0(( diff =3D $#string2 - 76 ))
=C2=A0=C2=A0 =C2=A0for (( dd=3D1; dd<diff; dd++ )); do spacer+=3D&= #39; '; done
=C2=A0=C2=A0=C2=A0 ... # spacer will be incorporated into string1, no= t shown.

It works fine, but I'll bet there's a less laborious way -- s= ome way of creating 'spacer' with=C2=A0 'diff' number of = spaces without the for loop.=C2=A0 I could make 'spacer' too long and then cut i= t at an index [diff], but I doubt that's as simple as it could be.=C2=A0 = I know it's there, I just can't quite remember.=C2=A0




--
Ma= rk J. Reed <mar= kjreed@gmail.com>


--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--000000000000066c510617d0bb5a--