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 20650 invoked from network); 16 Sep 2023 15:09:05 -0000 Received: from zero.zsh.org (94.142.241.90) by inbox.vuxu.org with ESMTPUTF8; 16 Sep 2023 15:09:05 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1694876945; b=OKc0+eARDLarV53Dr9kiRUFttOGTobJsXgG8RdNzKx0xWkN2MwnLDjZiyPaeu6S1qLx1pS8AUS GTdaB9zlibd/7RKT7xgtiHqqinGnfGGjEMddDJ4H3FPfAvg0vK9kODdyqjBnKZPS4gYJn0odHY +65NQRmD79Q5f1I2dV2gQNAtQrONMa2TjjJFnA24kZxhKKsv8Mk/uR6KdtW4aXyf7LIgRV8G4i eXQuqwKrv05xazkYdUdBTXoTd8ipXjeht3xMORxHMCEuLwhX7hcBWUaNw5JNnpXjyWXU8/HxN6 18qGwFtQAqh2kx4EJC4QxUGXlhUOtk81duOdP8v1f/+jPw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1694876945; bh=WtpvQ3lDydaCI6ULMGQtydtfao3mJLowbz71+GzZxjs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:MIME-Version:DKIM-Signature:DKIM-Signature:DKIM-Signature; b=XX/jnSl38datYEag+NnAClSoE7LDHf8ipHpg0CEph0uSlNq6wZjW216aqxsJ67lyZU6YaL42QE X3tuIXFmkdF9TMPevdXo1F3rqsSllm7XxLi2+qE2glou9dBrQw9sDP0oybm52Uajko1j28TifQ Ihv8b5vaGWCEWVGGcpTpPCyYunFas/EWaxUzrM8HBhytwtivYgJ0NhVtEkr7805aXgNISqi3BA uGHYqNbpRh/jTtOBv31I+Ka37FBxPy8bbHjWlP0Mh1fATBkL89p1On7OtvZ/nzcmvHSv5tdacR lIJYNn+vsHV6MsdLETl4e04v56+w5y9YRHpeQbTx5ECXag==; 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: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:In-Reply-To:References; bh=sd2jHMVz/VMYOf6QqROmy7JVTmkdtUq34vHb/MOtCbE=; b=jmtHnwbgA81xhnlpRvpoyZ1aeh lt6KHR0Tcvvp7C4l1u4jmL9mWyJ28rRDW31It2pVY2qlmkPHZ0k5/y/NURBEfy2Q2BwFR3C+6nDRL GvU8VXwXH/nBKXFm43ba1CLhJqmzX7svoCcfWZCC2u9P55yvkQoMc+eCtmX29g2idCkAwKf7KI3ms MJHhTOTcw1QJPScG32oDiDkcEt/Xv7xucJvHunb3m0Rw16tSnU8AmcOF+uD9N+6JpJZ5/csnymn0S ozawtONiNvzJSQvv4XIOn4Rv0IF29Jvg8dYjCUvFvIZq5AwctCHrEujgF+KlCBax3mowC4ivBRhlV tqX8JKWg==; Received: by zero.zsh.org with local id 1qhWus-0003iK-Ij; Sat, 16 Sep 2023 15:09:02 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f51.google.com ([209.85.218.51]:53319) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qhWuG-0003Nr-E2; Sat, 16 Sep 2023 15:08:26 +0000 Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-9a9f139cd94so407809266b.2 for ; Sat, 16 Sep 2023 08:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1694876904; x=1695481704; darn=zsh.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=sd2jHMVz/VMYOf6QqROmy7JVTmkdtUq34vHb/MOtCbE=; b=HMstX46LZDZNA2QbGQCTXPcWvPhQEMP7iyPgnO0anbwGe85IJbF2qsaEnds0GLpFRP uG7CRuKoHK3rNa07bI7fhe2H8MlJSPCAzecG7wlUtRYUDsxH0K3enIbWc41JWS/+Iez7 eNqJOf2xQPgEvNU0ZIxPY+OeomeWX56MIA6MNz07dq2mj2SES3t8WlyVAZd86xogVlny aDDZBqXQXkc0T9VIE6TyFKO7Yqyj5X9rom4wctxK6xnQOc0E36RWeIlC6q6F726FioGO xvJsCgtMFIRMje9BTJur0LK6CyAzA+Bt7DZLcGxYWNERb/NGVZV0VJdaTIvMbi8vjdTj CiUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694876904; x=1695481704; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sd2jHMVz/VMYOf6QqROmy7JVTmkdtUq34vHb/MOtCbE=; b=f4yULFOEmVLV/LcLSxsaE9YzFfqxx9hiWuYE90/GuxqZxkB0QePm89i4lnpem1BaWu SUhxLZsTK1AmtZGm0DwW0qBwbCGqT+XD5a4ZDa/RWHX5IJRuv9kb6mcR+BBO/SsPSyvY rWpBh7srmHPuvkSphHNfzXaFWd/y92ZBD9bUEKY2+pUaV9FI+nv7cjsAA3RxP45gN2j4 JhLtAQRARolc/d1IeJiYELDnBgiNCA2Hw5JfW5uAI8MXI2vPJZx8ADyJG7AlhQPvLwMo FWjppIXIFALvWc5YyZxL6sCPLQJ2ZNQWnJRLRi1niZSgTw4oN9AXDVzKwKpdoA/MojGk g7fg== X-Gm-Message-State: AOJu0Yz7cqkja3+bsyrxoO2AtB/f9vKwRmXXnaJhwmZRv1mUxeHin8E/ 4h0WV/GH7lBg+YGqXj0aZBwoUa4I7Ml4NBFfcLQNeLloVrBpr4zyla4= X-Google-Smtp-Source: AGHT+IFLWb28xsaxllZM5n6tQiRl4Sm5BmITidbj9zFPIT3Le7b0qhEjotHnq8auvV20Q5ayxcakV0vwm/X8b1Wijo8= X-Received: by 2002:a17:907:6087:b0:9a1:b967:aca9 with SMTP id ht7-20020a170907608700b009a1b967aca9mr3664235ejc.63.1694876903293; Sat, 16 Sep 2023 08:08:23 -0700 (PDT) MIME-Version: 1.0 From: Bart Schaefer Date: Sat, 16 Sep 2023 08:08:12 -0700 Message-ID: Subject: Bug: function calls with break in preexec To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 52151 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: This nofork test is what got me here: repeat 3 do purr ${ for x in 1 2 3 4 do (( x == 3 )) && break 2; print $x done } XX done This fails when added to the test suite because it produces no output at all. "purr" is a function: purr() { print -r -- "$@" } If "purr" is replaced by "print -r --" in the repeat loop, everything works as expected, the output is 1 2 XX Its important that the ${ ... } is expanded by preexec() before the function is called. After scratching my head for a while I came up with a way to have that happen even without the nofork patches: repeat 3 print c*(oe:'break':) prints all the files starting with "c" (e.g., run it in the zsh source tree) but only once. Conversely, repeat 3 purr c*(oe:'break':) prints nothing. "set -x" shows the function call being made, but it immediately stops without executing any commands. One of these cases has to be wrong: Either the loop should break immediately, so neither the builtin nor the function runs, or the function should run and then the loop should break. Or more radically, a break occurring in the argument expansions should just be discarded, but that seems wrong too. I think it's the former: The builtin shouldn't run in this case.