Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

=(...) on LHS of pipeline leaks tempfiles



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



Messages sorted by: Reverse Date, Date, Thread, Author