summaryrefslogtreecommitdiff
path: root/Functions/Zftp/zfrglob
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/zfrglob
parent1cd802357096b60561b1a50c0c23ab357bbc0de3 (diff)
downloadzsh-200accac63deae99eb9656b26363c85648bd6748.tar.gz
zsh-200accac63deae99eb9656b26363c85648bd6748.zip
34067: safe tempfile creation, part 1
Diffstat (limited to 'Functions/Zftp/zfrglob')
-rw-r--r--Functions/Zftp/zfrglob15
1 files changed, 8 insertions, 7 deletions
diff --git a/Functions/Zftp/zfrglob b/Functions/Zftp/zfrglob
index 1fb8d761a..5015be77b 100644
--- a/Functions/Zftp/zfrglob
+++ b/Functions/Zftp/zfrglob
@@ -33,12 +33,12 @@ if [[ $pat != *[][*?]* &&
( -n $zfrglob || $pat != *[(|)#^]* ) ]]; then
return 0
fi
-local tmpf=${TMPPREFIX}zfrglob$$
if [[ $zfrglob != '' ]]; then
- zftp ls "$pat" >$tmpf 2>/dev/null
- eval "$1=(\$(<\$tmpf))"
- rm -f $tmpf
+ () {
+ zftp ls "$pat" >|$1 2>/dev/null
+ eval "$1=(\$(<\$1))"
+ } =(: temporary file)
else
if [[ $ZFTP_SYSTEM = UNIX* && $pat = */* ]]; then
# not the current directory and we know how to handle paths
@@ -49,10 +49,11 @@ else
dir=/
fi
nondir=${pat##*/}
- zftp ls "$dir" 2>/dev/null >$tmpf
- files=($(<$tmpf))
+ () {
+ zftp ls "$dir" 2>/dev/null >|$1
+ files=($(<$1))
+ } =(: temporary file)
files=(${files:t})
- rm -f $tmpf
else
# we just have to do an ls and hope that's right
local fcache_name