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_EF,HEADER_FROM_DIFFERENT_DOMAINS,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 A092E24C40 for ; Fri, 5 Apr 2024 22:33:21 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1712349201; b=KyKHa1smKcR2MYn+MOrn15z8Ljc2uBXb2j0V6A7FejWt4rJ3rLweG7Ru1lX43H3diePBT5hgvb CJfTVlNZKio+fhGPEpbUGBMLemwkB24NDcnduDhSszCcXfz8CO76IlNIY5dfJAEgcXJqIAeukJ NbL7Vj8xgCuVpBe7y7Gf0A6Qm6BRyAg9l3jUPD0kTIwNjsizSD0NaoiBKgmjrmhq5GzQt8IojP ahAUBPmJoG1K9HaCUWiIkh5CAFG3tqd14xnW1mAyw8miWVN0C5zY7kUehZGpHz1ZXsz/+NouGI ErQNOZs1jJIeesZEY5tUnI5YSMLf0gsKU4jszJx2xXa0vQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f54.google.com) smtp.remote-ip=209.85.208.54; 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=1712349201; bh=HNj3jeK3tpMqmfjb+NE7T3R0bcD1aKQT9yFghnE38G4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=qk9QIKUQtuok/PuOXf6nJgOQZTGCah1Kh6cZcT+2fKGycpDzajLvU7Q0P03T39lo/CnxTXbYg0 e6WbwohqVhm8j51V+K1OrK6cT+enRhcE8kbmcWemUoEgbxbsE4Wj2Nqcrl0dfVG08uAcagL7No rNuzYZuq5DC779vWwS4X+a5YtstQMhXoz5Yi5FyEpR7lew3RI8jJSB2jg8mPftnuvfuEM8qyGP 0AVjKAdv692Z2zakHoxtg/YLajlobHvp1frxLPfgL+EDxEnppFPCNUwbTqRUN4S/wqcePqxckj GzMzTblXaapA2mqNlbQ/bbXKsEII6TItXNdJut2KGnld9w==; 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:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=e/NFh0209ylek+/cXJV4TkEk31ec2eUR5svRXsonVsc=; b=oS94qB+T/dFPXLPikZr+O/wQ69 zsccvkhftFLsgDB/UiTxcCMFqAp3Tl798dCHSXYpmNzS8hZji7vBH4qLT/bKX7QCbomzabQ22BHWe I0tPN/lqKBIO8vFa+Ypwbg8snKCmkAK/E35HF+MrNRffZ5Qg8eJ973yJky9+IIISUck/B50UajwLz fAajQ5GUIqXCl62oQ+NOoQ2S9S2JlACb0psbYxVDp+Dm1Qsm7HzINSVCMDR94F9fNS/Xtzr8bqeVt xZAFc/lUl44X2gg8TpPqDPWDi2sC3vjan8DoN4/So4ljvodnYY+hWs2ydHJuxbYP9HTls9Icif3JZ cDUMXVWw==; Received: by zero.zsh.org with local id 1rsqFU-0002zV-4F; Fri, 05 Apr 2024 20:33:20 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f54.google.com) smtp.remote-ip=209.85.208.54; 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-ed1-f54.google.com ([209.85.208.54]:54603) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rsqEc-0002Ju-Lf; Fri, 05 Apr 2024 20:32:27 +0000 Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-56e0acaf69aso3323147a12.1 for ; Fri, 05 Apr 2024 13:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1712349146; x=1712953946; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=e/NFh0209ylek+/cXJV4TkEk31ec2eUR5svRXsonVsc=; b=BPGqozHfONXMTbI9FdMEAfzbsIni81trKQ4FuhgfSNboejy9GIbViD1MuU/Ldj2IbK j5rLyJcEBnQkZQ1C3nDdGnkcz0viycqrrq5A2Ov/2lwTuF9xSDM1/EnzfQuXa7DzVWl2 uKSlGbDZyWSBvuT4n1UodQYRBzd8GXINkVFlUzetuUbWTlzPxcIIgEKBRNgHGmW6Zmw5 8MYJ7dzTMgFQpF5Y9b0oRl849bv6o8G15fE5FAdz/RcxJ/wQwpLTCLahXb9pcyESCyTr e5BSMlV+lNWo2746iQUJ59BFjkyHT935Fb/JpB3Abwzb2m06fO6CRdckVG+eJkyBhdZY 9FNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712349146; x=1712953946; h=content-transfer-encoding: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=e/NFh0209ylek+/cXJV4TkEk31ec2eUR5svRXsonVsc=; b=Xxsqw9AlvuXcDbjtz5W/kJBQgNgfXUUkk5v13TG5/PejPQwT0xSZCAfNHmdeGBuDTu G6AKgHGb7V/MIZRgtJDBXjZh9YRUccnNfZCA0a+TNWI5h0lvSlDYBnCTkCb/sxYv+nvO PaHJzBoNNclDHAYNAFQqE9CQ+rjQxUg39kAmlN+AL3fZawVgUycukDpuThc0wtgmytyU yijhccyO+D19VJ5gpRAjFEsVfSxrH1p96aMI6a37pqZCQD0oXFG0M3D6QMREB51Inkq0 bYQW4uffjpw/iGSuPgRt5Flh+BiC3tsqbiSioHjow0I5rmkcaeJyS7L3+2ACfwtjn7YE 7Q6A== X-Gm-Message-State: AOJu0YzHPKmyeSVy/bOWofyouN0ZfZ/D1nBeyNpzXWLyYcgKuOroMqME a+dbdyzmsq2327dROYXN6w+kKyrBNEkzgCiAD/FPDAJaVx3iVVKwduVC5r6pAdTK01ubusVtfFn gD/YOBzv+OlwkcoOMcXsd7mJEneLyT8EwyKHbI4bl7zvhhCWh2g== X-Google-Smtp-Source: AGHT+IEb8eh1d2dY1TDzSHCaJXPBoWSF6hQtzkHpDtzRFv1RQXm1E+mdNz+O1Hjd3RRFfUU8xAJ0jHqkfM8a7IBBMZ4= X-Received: by 2002:a17:906:1348:b0:a51:a420:9f12 with SMTP id x8-20020a170906134800b00a51a4209f12mr1534818ejb.72.1712349145648; Fri, 05 Apr 2024 13:32:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Fri, 5 Apr 2024 16:32:14 -0400 Message-ID: Subject: Re: piping surprise To: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29778 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: On Wed, Apr 3, 2024 at 11:49=E2=80=AFAM Ray Andrews wrote: > > I believe Bart had a solution to that. I can't think what you're referring to, but in the realm of the baroque ... typeset -gi Pnum alias -g '|'=3D'> ${TMPPREFIX}pipe$$.$((++Pnum)) ; < ${TMPPREFIX}pipe$$.$((= Pnum))' This uses global aliasing to replace the '|' token with I/O redirection through a (relatively) uniquely named temporary file. Only works if the left side actually finishes writing so that the right side can start reading. However, there's a bug (?) in that if you chain together several commands this way, only the first $((++Pnum)) actually increments the parameter, so all the commands end up with the same file names. E.g. echo foo | tr a-z A-Z | cat just prints "foo". You can see this by writing it all out and inserting an extra "echo": echo PIPE > pipe.$((++Pnum)); echo $Pnum;\ < pipe.$((Pnum)) cat > pipe.$((++Pnum)); echo $Pnum ; < pipe.$((Pnum)) cat This will echo the same number twice, where it should echo consecutive numbers. This only happens if the autoincrement appears in a redirection.