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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5955 invoked from network); 20 Oct 2021 17:37:23 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Oct 2021 17:37:23 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634751443; b=JnciLBwSFowP+dVNpdsIW2BOnCsstovQv1qEXrtkiE3D/12UAXRSJYa47C7M7Odn309tvM00sr N8g/e9QghT1VBZwkeFn5dZwQ9CAztm1l3XTqU3aeYk3rR9PzYSfoNvlLp03i/NyVr7/4EnVEwt Dt1Qshr5Vv2US4zdbct4kOHFj+P6udXFIKTU58RN3Cu9MQ8UqIxG3gJRCOA6aLkDDupRagIgFS jKVDxYXnxbLaPvS/aGCl2CaXdbpyZuAGoXJBuWZsjRKzhJuHTMA0ev5D/93nWKrxdm9VgDL1P6 nTfj048Myoxyz+Iryjs5sNUmpv0wEwJmPoqs0jeciKhECw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 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=1634751443; bh=oCMUVm7goN8X100fy3gwFrC5SOzEZhVCaIKgO9jmb1U=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=r1HKAWbyy67ILAQupZzGYiyELYlg4dBOEtTRW4KalFv6vaqbYiApyoNHbSGyf4jUhiy8wN0YiN 0i53gbh4pWGLqdzrqj4C/NmB/w2arWZ/kh4PDkTNHT0W0zoSDUQ7OWd5s/LOMMVqR/RRpsKsvA WoHLQGvFk+zC2IinGQbUaQ86qgcnIJT97Sh2ZUhb1NPCbZBltCUF8ZSPBfCKDNciS3bRtJmkAd MAbmXHWBkHTtIv556q4KeqMZXKrypdDUKuKzMAxS87yk1By9hKkM83Tf1YzRCmZ984T6fN0fKY jItFYlJOqe9PHdb6QZuGKYW5ilggClJDXMccLNvggmykYQ==; 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:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Es8Tmbj8Xm8VFVDecVM2fYW9nE/kXMf5P9DobT/oqAM=; b=J6gN8SED5g99hTQrQFQpi7hlfd EcKkw8f60u+cFIdDt4Hzri78zW+vO4Ms704N3zdwWvDCjfzr/cA+DvKfrqdYSYiikN0t0UuPdy4LO hpi/DvBKWh2zYv4q6uuhtRGaGC7cQ2zJhC/HdfS+xR7He1CEKIX8kALzmCD6YYcvdHwpG1GAzZ6uj y5Jk0nsVq1j4X91r2YpkrlirmMuVMZaFUT2NU5bYb3CFcgIG52e8TlOb9AmydbW1iMWQoaG2XILUU 8uOX1efbVz9zeFSiruKycZgU+SqvuPC9OretI7JIiog7tDJ46L8b1h0+eVcxcs6Ig+O8DkjOhLUjO /bgbZzAQ==; Received: from authenticated user by zero.zsh.org with local id 1mdFWk-0004U9-1k; Wed, 20 Oct 2021 17:37:22 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f174.google.com ([209.85.219.174]:42533) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mdFVd-0003le-Ms; Wed, 20 Oct 2021 17:36:15 +0000 Received: by mail-yb1-f174.google.com with SMTP id l201so3195760ybl.9 for ; Wed, 20 Oct 2021 10:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Es8Tmbj8Xm8VFVDecVM2fYW9nE/kXMf5P9DobT/oqAM=; b=RoGrbBIibDu6zuHFIH1XL2l1bLW2ElN9p+B0BbfhtgTxLtAXvjdKXt0c5irQf0k9LE SYWAJJbCaSiYJYZLg7Rls+HckWY8jKY0Uk40ROQfadoDr7KDJQnY9KTV/nN+uD3z8WYw KKGAuz7OcNsCaJZZNXco0yVK8MQDl65MTEhig/Wn/kFay4oBANv+7EJUpIuWkd5aZWhj ZkQ+DvTSUFjsl1f/pZ7ZHmy/JwWmWbcc8DwUp0Pn4qOi/FNGlEuwaHjzEtEXYsXEDO6f y4wF36Nky1KBjauKYzzxv9fanoxvnhxgHNISC3Ky71zUsJ7ZxIPIfXo6cAwrNUJiVG+M DDvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Es8Tmbj8Xm8VFVDecVM2fYW9nE/kXMf5P9DobT/oqAM=; b=gZGpqkyJ0vj9ZEdaE/Q5cmb4f4GHMQ0e+yslPFXdk9docQv5S1ml/zZFw6tY1xOxQW uIEtYJW43pNIZhAy4wdDBOqfAGOGaaawNmt5UYPPQzXQjTZHKHoVBBsZcIovM2zhPHFa 85h4nslbrTDHRzyK5GVM7jLJMABgRTqsIrB4t5mo73EsSTz3RV67vdkJaAq1nPKj1TyG Bs+bPqm4QTJkbhJY9/wELqBFuhJmnGG6oEu8mQq6c1eOQzegWbROvxDliVen4+QD8x9S dReqHLN/BdKDlwR18HfeHHrrY3nHqC/+KizfUuu24oQgAIWRhjvFyUbubgllppDfOptB QG0Q== X-Gm-Message-State: AOAM530VLXl0mcKVeWHu3V7xqZ3T6u2fOCGNWSuIdEu8DfccI9pDhGNW hPnzf8nEJ7hYsutCFMTRKyYta7j9/X1PD1Dv5WoHE6qu/6ltRA== X-Google-Smtp-Source: ABdhPJzR8l3+QZnD+tgrvmjnSy9KHhHuUFwPnViVa41h/OMGG9wWHBbTKexh9xne6ODofXfI1vsC9Qjjqv44K89HJJA= X-Received: by 2002:a25:7e46:: with SMTP id z67mr458888ybc.166.1634751372217; Wed, 20 Oct 2021 10:36:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Wed, 20 Oct 2021 10:36:00 -0700 Message-ID: Subject: Re: Temporary redirection of named file descriptors To: Zach Riggle Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27252 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 Tue, Oct 19, 2021 at 12:50 PM Zach Riggle wrote: > > TL;DR: How can I redirect a named file descriptor (to e.g. /dev/null), but only for one statement? The short answer is that you can't do what you're trying to do in the way you're trying to do it. The {myfd}> syntax is defined to create a new value in $myfd, and the N> syntax can only be used for N from 0 through 9, so there's no way to use the latter to re-redirect a descriptor created by the former (which are all numbered more than 10). So you have to do it something like this (example using an anonymous function): function { local zshlog : {zshlog}>/dev/null somefunc "$@" {zshlog}>&- } ... args for somefunc ... > This is generally achieved per-statement or for a statement-list. > > >$zshlog command echo foo bar I presume that should be >&$zshlog