From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17478 invoked by alias); 20 Apr 2016 20:34:39 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21463 Received: (qmail 21184 invoked from network); 20 Apr 2016 20:34:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=jrJE21ZP5oMQlOxoL5NAKekxWn4EEwwmsRXGmVYesjQ=; b=O4EH5TrkhZn1nrD7WRR0YIV9TQ4QPtTV5pDmq2SWZof2/9FEdfds4s4kkZQLds1VSg 278rIT7KmCnonOWtybtGOj4x4Y9KCYAmLp3MFcjOl1vaygD3eaPKpA4uNa9F02g0FhMV zUOWDJjqY6DYcsfSYBjWX5saNJZMDFYN3rbgZhMxBrAAQjjfJxQYKxQvTJZHmi5lx+h+ j8BxSbdlbUSFBKk5M4J7idI0A+UpQuHJJbB73evcCRXplIXqFhKdlnEFj9hp6CkwsFYw XY4RBd4QreDsxUU845KqFysxVbUfpp/EnMkAIfROx7aGyNvrQPb+SucVa6L9RbD5d9TB cCVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=jrJE21ZP5oMQlOxoL5NAKekxWn4EEwwmsRXGmVYesjQ=; b=AFpNTqScd4el6ZLtGIQ4L/77BPv3fWK0zHuZLeR04Yem1P79gpVdcc+BksZo0yC/QW r7fZKl96WHH9bqQaDP/QlNK1zBd5YEpHEFnO4+Ytu+E/wK9hEC/W3lALGFAh8dVjCebx w4PHjRqBTdawTnrZ5L3H6vaj2V06eFr6lK5+OkB6bHEi6D7nPkibcpJpOriguVnI7ORE smDHqKx1IReCsvZ1r+xIDK1Cea3jLsd/UAxzTNsn64vTNHsjyx8RzRp33HvHSenf74CA o/lutcjBTG3tVjW/xXipSonnpM4cl1Uz5ErPxO1tgsgqiysxCteYLL5vc9dB+pw1sldx lLdg== X-Gm-Message-State: AOPr4FW/qFavD6mK6chaSniH0IbG6itsmjIrBBqLQ/tGHcNlqFkL+kZk1oujmXkEhm/3UQ== X-Received: by 10.66.253.68 with SMTP id zy4mr14989114pac.81.1461184473676; Wed, 20 Apr 2016 13:34:33 -0700 (PDT) From: Bart Schaefer Message-Id: <160420133446.ZM13832@torch.brasslantern.com> Date: Wed, 20 Apr 2016 13:34:46 -0700 In-Reply-To: Comments: In reply to "Benjamin R. Haskell" "Re: virtual files?" (Apr 19, 11:32pm) References: <8760vdrt5y.fsf@student.uu.se> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh-Users List Subject: Re: virtual files? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 19, 11:32pm, Benjamin R. Haskell wrote: } } Using the `=()` substitution ZyX mentions: } } () { } local tmp=$1 } wget -q $link -O $tmp } echo -n \$ } grep \"answer\" $tmp | cut -d \$ -f 2 | cut -d \< -f 1 } } =(:) } } The '() { ... }' construct is an anonymous function, just for controlling } the scope of the temporary file, and for passing it in as a positional } parameter. It has the disadvantage that it won't remove the tmp file if } something goes wrong. In fact the point of using =(:) is that it WILL remove the tmp file if something goes wrong (unless it's something completely catastrophic like the shell itself crashing, but in that case an explicit "rm" wouldn't work either). Instead of exit traps, you can use "always" blocks: () { local tmp=$1; { : do stuff with $tmp exit } always { rm $tmp } } =(:)