From 200accac63deae99eb9656b26363c85648bd6748 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sat, 27 Dec 2014 23:59:29 -0800 Subject: 34067: safe tempfile creation, part 1 --- Functions/Zftp/zfrglob | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Functions/Zftp/zfrglob') 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 -- cgit 1.4.1