From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7107 invoked from network); 19 Jan 2023 17:03:17 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Jan 2023 17:03:17 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674147797; b=UpQEegmox3MiNAbAQPA2etXPwR7TONvcnzOq6gWoZtHzgNObWGydIdorcg+jx0utfwMivoE9/k 8JaRl7v5ueBAOapfxR0Y0yOoMhplhaYulQgbGrXQvhsl9fP9Iywm5gZeHZuJWL0M8x1R4cS0N1 o5qyPQu80JsdcTsdTKFCuvzRpa8ElmpK7US3K+6OOlIXoYWDRhrQJyooB6F42dym2aEOyZbJUM xocjEMvsX7zg2NpU2wuxyosqX0ymGtX8PH71Yt9+gTmdbtPfDMFTiS8dLG6b5leze5pGOLa0gS yFSwqtl7672GyaSHkTUF8KHC1oAwFSy+5QNj0+A6yS5i2A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1674147797; bh=rZpgI26Fnj48i1e9gEdmou/Qa4sSU0bYkF08QgdiXgI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:To:From:Date: References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=j0dorXKrxPJd8SkG3sEmgO80JTLyJ9Gmw1JPNNrQ5WcwnMuZym3Pawu4qu/4ctiOHODcCIhj9Q zdsLLy93EzL6d6aQENTyfAiy9nsIKSeKkS+udKbxwWpo4SWbbBKVLoug+Cx8srRcsxrYvRwYC6 ETdRJVpDpJy8P9lJgjkZDz5fTP3klGbfX9y0eQekXjot9GFLGsmpINykef2Ga/wNJzzOWR4GkQ h1mqteuEKDJmf8YAuWXoS4VrZzAZSnaE+4Tf3xjcXZJMLNeoTRTi17sGgYftOpW19Kkte0B9QE MFpqqgsji5GchszVWSPGMRyuHGMt9sStMDEtRI27p+3RCQ==; 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-Transfer-Encoding: Content-Type:Subject:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=FpTnRcyZT5ClAa8JeQPX1IyOzxT46yIwxFU8QMJqBMk=; b=TtHySJhDE0s8m/ZZi3bQYy2dt6 ZSbjzbEr3aavDh7nfAeQAYoNQuz0A3UBJErw50raO3OBC2ELLlSnXOY8Ozu7y4ghyJCDjHw4VMkb4 daUoSi0blykNd5zJEsNogSUryRBhbAOpxiRPaMF6LEDKVm9C320FZAdZ1qeTf8CqZbBJA1Re9bYu7 rg0vbnB5e5LxBbArHpad9930QP8HI0RGg9a7xDXG5b3BaivbZm1EQFkU72P4Rij2Vz/vW6wX5YuXh uq4/nii5Os4tbtdT7h2qip8TQtAR3yCY6XZ7blJhezcctBYp3YvwpFjuKg58d1QvZsH+wcKnhHuR5 qnrq6K0Q==; Received: by zero.zsh.org with local id 1pIYJo-000DJE-Kf; Thu, 19 Jan 2023 17:03:16 +0000 Authentication-Results: zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out3-smtp.messagingengine.com ([66.111.4.27]:38201) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pIXv5-0008LD-Kc; Thu, 19 Jan 2023 16:37:45 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5B70B5C0004 for ; Thu, 19 Jan 2023 11:37:42 -0500 (EST) Received: from imap46 ([10.202.2.96]) by compute4.internal (MEProxy); Thu, 19 Jan 2023 11:37:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm2; t=1674146262; x=1674232662; bh=FpTnRcyZT5ClAa8JeQPX1IyOz xT46yIwxFU8QMJqBMk=; b=bHNZEB//PblTF2dwUm1vuPNi3hnsbbBv+N8DHJMIh 8L2R2iZzcPuVofSvpLXkpzHEgUN/shtO7Et96rYW/7FzbaK2Fs1KvhiKlKcI5Eas 0aQwJUD/ps+w6av5KW75KmGJ29hedRzOJ3HZAWrv5+M1dDBFPTs+tONBGivYvUhB ZDJaOH+9xYLYGz+M30RfcfV+LCzbXeM17LLH+EJF9TH5k2LvxfsxJ577cQA7TrP5 8If8wHtnAqVMg8F9SMwRMbeCzCRJQmL7pgEGFVTr1d/KeER9AglbX2S6nwwRPP82 t7oBqRa8mAc06gUhLVMOmenh/xrJ/8b984ZvFqOUIR18Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1674146262; x=1674232662; bh=F pTnRcyZT5ClAa8JeQPX1IyOzxT46yIwxFU8QMJqBMk=; b=szOUEQwui4/p/1DCf vtLEpjy4rwjX25MqbtWyyQ9obzNPJVdAIviCunhW1FrrIF+JhvS18VFdfBoh+6xw xziWBptgyf9oFR8hgdGzBh2E0v1yaclZr059oAlKl3mmTg7mV+WUAuL60nquYGLT dqoSTZI0+pShmCK1A2g0iLoLvzmiD1JeCw8h9ZFBtlht2csixwIEdK3JQeJ+XC+1 hTxSj2jWtSrsrWdofnSXVg86YGJKJtlkHAchy1hBTj7+zhThQ8fEyqVize3lX4M7 366e/qveH3WwWSN39JlcMX90l3VGxphYB+jr/JVTHXx+npsJ6s1fFAkiQou7dl3b Q3UyA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddutddgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepfdffrghnihgvlhcuufhhrghhrghffdcuoegurdhssegu rghnihgvlhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepfefhkeefve eileelheeiffdtkedujeelvdfhtdejtdeggedvuefffeelhefhvdfgnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrd hshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 2791B2A20080; Thu, 19 Jan 2023 11:37:42 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-85-gd6d859e0cf-fm-20230116.001-gd6d859e0 Mime-Version: 1.0 Message-Id: In-Reply-To: References: Date: Thu, 19 Jan 2023 16:37:08 +0000 From: "Daniel Shahaf" To: zsh-users@zsh.org Subject: Re: repeat count? Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 28674 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: zeurkous@blaatscaahp.org wrote on Thu, 19 Jan 2023 14:57 +00:00: > On Mon, 16 Jan 2023 20:20:13 +0100, Roman Perepelitsa=20 > wrote: >> On Mon, Jan 16, 2023 at 7:06 PM Dominik Vogt wr= ote: >>> >>> Is it possible to get the pass number of a repeat loop from within >>> the loop, or is it necessary to use a hand written counter? >> >> I just realized that none of the replies actually answered your >> question. There is no special parameter set by the shell that contains >> the iteration counter in repeat loops. I'd love to have that myself. > > Then the question is: how would that work w/ nested repeat loops...? Let's see. Draft requirements: - Count from 1 upwards, incremented by 1 each iteration. - Be read-only.=C2=B9 - Remain set after the loop ends, to facilitate testing it to determine which iteration, if any, ran =C2=ABbreak=C2=BB. - Be possible to have a =C2=ABrepeat=C2=BB loop call a function and afte= rwards access its own iteration count, even if the function executes its own =C2=ABrepeat=C2=BB loops. So: - The variable could have a well-known name, and loops that call functions before referencing the variable will need to save its value locally. - The variable's name could be specified by the user, as in =C2=ABrepeat= -v i 42=C2=BB and then store the iteration number in $i. This would be backwards incompatible in a corner case (the first word after =C2=ABrepeat=C2=BB= is a math expression, so syntaxes of the form =C2=ABrepeat -foo=C2=BB or =C2=ABr= epeat --bar=C2=BB are valid today if SHORT_REPEAT hasn't been turned off). - Or perhaps the arithmetic for() is good enough for now and we don't need this syntactic sugar at all. Cheers, Daniel =C2=B9 Mainly because I don't want to think about =C2=ABrepeat -v i 10 (= (++i))=C2=BB right now. If someone wants to spec a writable repeat count, go ahead.