summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-09-29 14:55:49 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-09-29 14:55:49 -0700
commit736eb433bae71a162f8b5adbd42710bb718a3c91 (patch)
tree28dca749a51600b1de4394dcf4595b2fe853226d
parente61ed2b80d60ca095006d7512f90c07e6c572ee0 (diff)
downloadzsh-736eb433bae71a162f8b5adbd42710bb718a3c91.tar.gz
zsh-736eb433bae71a162f8b5adbd42710bb718a3c91.tar.xz
zsh-736eb433bae71a162f8b5adbd42710bb718a3c91.zip
39507: TMPSUFFIX for =(...)
-rw-r--r--ChangeLog2
-rw-r--r--Doc/Zsh/params.yo9
-rw-r--r--Src/exec.c9
3 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f93bdb10a..3fe3165ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2016-09-29  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 39507: Doc/Zsh/params.yo, Src/exec.c: TMPSUFFIX for =(...)
+
 	* 39470: Src/exec.c, Src/utils.c: failure to open a supposedly
 	unique temp file name should result in an error; band-aid for
 	signal-related race conditions in temp file name generation
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 03625ce24..c7d84b9a8 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1547,6 +1547,15 @@ A pathname prefix which the shell will use for all temporary files.
 Note that this should include an initial part for the file name as
 well as any directory names.  The default is `tt(/tmp/zsh)'.
 )
+vindex(TMPSUFFIX)
+item(tt(TMPSUFFIX))(
+A filename suffix which the shell will use for temporary files created
+by process substitutions (e.g., `tt(=LPAR()var(list)RPAR())').
+Note that the value should include a leading dot `tt(.)' if intended
+to be interpreted as a file extension.  The default is not to append
+any suffix, thus this parameter should be assigned only when needed
+and then unset again.
+)
 vindex(watch)
 vindex(WATCH)
 item(tt(watch) <S> <Z> (tt(WATCH) <S>))(
diff --git a/Src/exec.c b/Src/exec.c
index 04868bd37..e253d7b9e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4421,6 +4421,15 @@ getoutputfile(char *cmd, char **eptr)
 	if (!s)
 	    child_unblock();
 	return NULL;
+    } else {
+	char *suffix = getsparam("TMPSUFFIX");
+	if (suffix && *suffix && !strstr(suffix, "/")) {
+	    suffix = dyncat(nam, unmeta(suffix));
+	    if (link(nam, suffix) == 0) {
+		addfilelist(nam, 0);
+		nam = ztrdup(suffix);
+	    }
+	}
     }
     addfilelist(nam, 0);