1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

34068: create tempfiles without forking, and safe temp directory creation

This commit is contained in:
Barton E. Schaefer 2014-12-28 00:49:08 -08:00
parent 200accac63
commit 33b3958064
13 changed files with 32 additions and 18 deletions

View file

@ -1,3 +1,14 @@
2014-12-28 Barton E. Schaefer <schaefer@zsh.org>
* 34068: Completion/Base/Widget/_complete_debug,
Completion/Unix/Command/_cvs, Completion/compinstall,
Functions/Calendar/calendar, Functions/Zftp/zfcd_match,
Functions/Zftp/zfcget, Functions/Zftp/zfcput,
Functions/Zftp/zfget_match, Functions/Zftp/zfrglob,
Functions/Zftp/zftransfer, Functions/Zftp/zfuget,
Functions/Zftp/zfuput: create tempfiles without forking, and
safe temp directory creation
2014-12-27 Barton E. Schaefer <schaefer@zsh.org>
* 34067: Completion/Base/Widget/_complete_debug,

View file

@ -9,7 +9,7 @@ local pager w="${(qq)words}"
integer debug_fd=-1
{
if [[ -t 2 ]]; then
mv -f =(:) $tmp &&
mv -f =(<<<'') $tmp &&
exec {debug_fd}>&2 2>| $tmp
fi

View file

@ -704,15 +704,18 @@ _cvs_sub_modules() {
_cvs_run() {
local cvsroot="$1" dir="$2"
shift 2
local d=/tmp/zsh-cvs-work-$$
mkdir $d >&/dev/null
cd $d
mkdir CVS >&/dev/null
local d=${TMPPREFIX:-/tmp/zsh}-cvs-work-$$
rm -rf $d
mkdir $d &&
(
chmod 0700 $d &&
builtin cd -q $d &&
mkdir CVS >&/dev/null || return 1
print -r - "$cvsroot" > CVS/Root
print "$dir" > CVS/Repository
print D > CVS/Entries
CVS_IGNORE_REMOTE_ROOT= cvs "$@"
cd $OLDPWD
)
rm -rf $d
}

View file

@ -1958,8 +1958,8 @@ if [[ -z $ifile || -d $ifile ]] ||
fi
local tmpout=${TMPPREFIX:-/tmp/zsh}compinstall$$
mv -f =(:) $tmpout && # safe tempfile creation
mv -f =(:) ${tmpout}x || return 1
mv -f =(<<<'') $tmpout && # safe tempfile creation
mv -f =(<<<'') ${tmpout}x || return 1
#
# Assemble the complete set of lines to

View file

@ -254,7 +254,7 @@ if (( verbose )); then
fi
local mycmds="${TMPPREFIX:-/tmp/zsh}.calendar_cmds.$$"
mv -f =(:) $mycmds
mv -f =(<<<'') $mycmds
# start of subshell for OS file locking
(

View file

@ -29,7 +29,7 @@ if [[ $ZFTP_SYSTEM = UNIX* ]]; then
# () {
# zftp ls -LF $dir >|$1
# reply=($(awk '/\/$/ { print substr($1, 1, length($1)-1) }' $1))
# } =(:)
# } =(<<<'')
[[ -n $dir && $dir != */ ]] && dir="$dir/"
if [[ -n $WIDGET ]]; then
_wanted directories expl 'remote directory' \

View file

@ -43,7 +43,7 @@ for remlist in $*; do
zftp remote $rem >|$1
rstat=$?
remst=($(<$1))
} =(: temporary file)
} =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not support SIZE command.\n" \
"Assuming you know what you're doing..." 2>&1

View file

@ -43,7 +43,7 @@ for loc in $*; do
zftp remote $rem >|$1
rstat=$?
remst=($(<$1))
} =(: temporary file)
} =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not support remote status commands.\n" \
"You will have to find out the size by hand and use zftp append." 2>&1

View file

@ -10,7 +10,7 @@ fi
if [[ $ZFTP_SYSTEM == UNIX* && $1 == */* ]]; then
setopt localoptions clobber
local tmpf=${TMPPREFIX}zfgm$$
mv -f =(:) $tmpf
mv -f =(<<<'') $tmpf
if [[ -n $WIDGET ]]; then
local dir=${1:h}

View file

@ -38,7 +38,7 @@ if [[ $zfrglob != '' ]]; then
() {
zftp ls "$pat" >|$1 2>/dev/null
eval "$1=(\$(<\$1))"
} =(: temporary file)
} =(<<<'temporary file')
else
if [[ $ZFTP_SYSTEM = UNIX* && $pat = */* ]]; then
# not the current directory and we know how to handle paths
@ -52,7 +52,7 @@ else
() {
zftp ls "$dir" 2>/dev/null >|$1
files=($(<$1))
} =(: temporary file)
} =(<<<'temporary file')
files=(${files:t})
else
# we just have to do an ls and hope that's right

View file

@ -47,7 +47,7 @@ if [[ -n $style && $style != none ]]; then
() {
zftp remote $file1 >|$1 2>/dev/null
array=($(<$1))
} =(: temporary file)
} =(<<<'temporary file')
[[ $#array -eq 2 ]] && ZFTP_TSIZE=$array[1]
fi

View file

@ -72,7 +72,7 @@ for remlist in $*; do
zftp remote $rem >|$1
rstat=$?
remstats=($(<$1))
} =(: temporary file)
} =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not implement full command set required." 1>&2
return 1

View file

@ -58,7 +58,7 @@ for rem in $*; do
zftp remote $rem >|$1
rstat=$?
remstats=($(<$1))
} =(: temporary file)
} =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not implement full command set required." 1>&2
return 1