zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: =(...) on LHS of pipeline leaks tempfiles
Date: Sun, 5 Jul 2020 15:05:35 +0000	[thread overview]
Message-ID: <20200705150535.GA21561@tarpaulin.shahaf.local2> (raw)

In «command true =(true) =(true) | :», the tempfiles created by the two
=(…) substitutions aren't removed.

Test case:

diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst
index 68a68ef6e..3d4931e48 100644
--- a/Test/D03procsubst.ztst
+++ b/Test/D03procsubst.ztst
@@ -160,3 +160,12 @@
   $ZTST_testdir/../Src/zsh -df -o shfileexpansion -c 'cat =(echo hi)'
 0:EQUALS expansion followed by =(...) (sh ordering) should work
 >hi
+
+  () {
+    local TMPPREFIX=$PWD/tmp
+    command true =(true) =(true) | :
+    print -rC1 -- $TMPPREFIX*(N)
+  }
+0f:external command with =(...) on LHS of pipeline cleans up its tempfiles
+# (Expected result: no output.)
+

Its output:

/home/daniel/src/zsh/./Test/D03procsubst.ztst: starting.
--- /tmp/zsh.ztst.21317/ztst.out        2020-07-05 14:51:27.564872915 +0000
+++ /tmp/zsh.ztst.21317/ztst.tout       2020-07-05 14:51:27.576872865 +0000
@@ -0,0 +1,2 @@
+/tmp/zsh/Test/procsubst.tmp/tmp7CIMPd
+/tmp/zsh/Test/procsubst.tmp/tmpEiQwks
Test /home/daniel/src/zsh/./Test/D03procsubst.ztst failed: output differs from expected as shown above for:                                                                                                        
  () {
    local TMPPREFIX=$PWD/tmp
    command true =(true) =(true) | :
    for i in $TMPPREFIX*(N) ; do print -r -- $i; done
  }
Was testing: external command with =(...) cleans up its tempfiles

I did find this bit in the manual:

    Another problem arises any time a job with a substitution that requires
    a temporary file is disowned by the shell, including the case where
    `tt(&!)' or `tt(&|)' appears at the end of a command containing a
    substitution.  In that case the temporary file will not be cleaned up as
    the shell no longer has any memory of the job.  A workaround is to use
    a subshell, for example,
    
    example(LPAR()mycmd =(myoutput)RPAR() &!)

but it didn't seem applicable.

Cheers,

Daniel

                 reply	other threads:[~2020-07-05 15:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200705150535.GA21561@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).