diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2014-12-27 23:59:29 -0800 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2014-12-27 23:59:29 -0800 |
commit | 200accac63deae99eb9656b26363c85648bd6748 (patch) | |
tree | bd0461e34cb47f0f4f26e339efbc5cda479b0c2b /Functions/Zftp/zfcget | |
parent | 1cd802357096b60561b1a50c0c23ab357bbc0de3 (diff) | |
download | zsh-200accac63deae99eb9656b26363c85648bd6748.tar.gz zsh-200accac63deae99eb9656b26363c85648bd6748.tar.xz zsh-200accac63deae99eb9656b26363c85648bd6748.zip |
34067: safe tempfile creation, part 1
Diffstat (limited to 'Functions/Zftp/zfcget')
-rw-r--r-- | Functions/Zftp/zfcget | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Functions/Zftp/zfcget b/Functions/Zftp/zfcget index 476a730a6..435980113 100644 --- a/Functions/Zftp/zfcget +++ b/Functions/Zftp/zfcget @@ -14,7 +14,7 @@ emulate -L zsh [[ $curcontext = :zf* ]] || local curcontext=:zfcget local loc rem stat=0 opt opt_G opt_t remlist locst remst -local tmpfile=${TMPPREFIX}zfcget$$ rstat tsize +local rstat tsize while getopts :Gt opt; do [[ $opt = '?' ]] && print "zfcget: bad option: -$OPTARG" && return 1 @@ -39,10 +39,11 @@ for remlist in $*; do else # Compare the sizes. locst=($(zftp local $loc)) - zftp remote $rem >$tmpfile - rstat=$? - remst=($(<$tmpfile)) - rm -f $tmpfile + () { + zftp remote $rem >|$1 + rstat=$? + remst=($(<$1)) + } =(: temporary file) if [[ $rstat = 2 ]]; then print "Server does not support SIZE command.\n" \ "Assuming you know what you're doing..." 2>&1 |