about summary refs log tree commit diff
path: root/Functions/Zftp/zfuget
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-12-27 23:59:29 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2014-12-27 23:59:29 -0800
commit200accac63deae99eb9656b26363c85648bd6748 (patch)
treebd0461e34cb47f0f4f26e339efbc5cda479b0c2b /Functions/Zftp/zfuget
parent1cd802357096b60561b1a50c0c23ab357bbc0de3 (diff)
downloadzsh-200accac63deae99eb9656b26363c85648bd6748.tar.gz
zsh-200accac63deae99eb9656b26363c85648bd6748.tar.xz
zsh-200accac63deae99eb9656b26363c85648bd6748.zip
34067: safe tempfile creation, part 1
Diffstat (limited to 'Functions/Zftp/zfuget')
-rw-r--r--Functions/Zftp/zfuget15
1 files changed, 8 insertions, 7 deletions
diff --git a/Functions/Zftp/zfuget b/Functions/Zftp/zfuget
index c1033c930..7bdaedc47 100644
--- a/Functions/Zftp/zfuget
+++ b/Functions/Zftp/zfuget
@@ -26,7 +26,7 @@
 emulate -L zsh
 
 [[ $curcontext = :zf* ]] || local curcontext=:zfuget
-local loc rem locstats remstats doit tmpfile=${TMPPREFIX}zfuget$$
+local loc rem locstats remstats doit
 local rstat remlist opt opt_v opt_s opt_G opt_t
 integer stat do_close
 
@@ -66,12 +66,13 @@ for remlist in $*; do
       doit=y
       remstats=()
       if [[ -f $loc ]]; then
-	zftp local $loc >$tmpfile
-	locstats=($(<$tmpfile))
-	zftp remote $rem >$tmpfile
-	rstat=$?
-	remstats=($(<$tmpfile))
-	rm -f $tmpfile
+	() {
+	  zftp local $loc >|$1
+	  locstats=($(<$1))
+	  zftp remote $rem >|$1
+	  rstat=$?
+	  remstats=($(<$1))
+	} =(: temporary file)
 	if [[ $rstat = 2 ]]; then
 	  print "Server does not implement full command set required." 1>&2
 	  return 1