1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 04:40:59 +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

@ -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