summaryrefslogtreecommitdiff
path: root/Completion/compinstall
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/compinstall')
-rw-r--r--Completion/compinstall15
1 files changed, 10 insertions, 5 deletions
diff --git a/Completion/compinstall b/Completion/compinstall
index c04543c57..afa517edb 100644
--- a/Completion/compinstall
+++ b/Completion/compinstall
@@ -3,6 +3,8 @@
emulate -L zsh
setopt extendedglob
+zmodload -F zsh/files b:zf_ln || return 1
+
local key
local compcontext=-default-
@@ -1958,11 +1960,14 @@ if [[ -z $ifile || -d $ifile ]] ||
fi
local tmpout=${TMPPREFIX:-/tmp/zsh}compinstall$$
+zf_ln -fn =(<<<'') $tmpout && # safe tempfile creation
+zf_ln -fn =(<<<'') ${tmpout}x || return 1
+
#
# Assemble the complete set of lines to
# insert.
#
-__ci_output >$tmpout
+__ci_output >>$tmpout
if [[ -n $ifile ]]; then
if [[ $ifile != *(zshrc|zlogin|zshenv) ]]; then
@@ -1984,15 +1989,15 @@ future use."
fi
if { { grep "$endline" $ifile >/dev/null 2>&1 &&
sed -e "/^[ ]*$endline/r $tmpout
-/^[ ]*$startline/,/^[ ]*$endline/d" $ifile >${tmpout}2 } ||
- { cp $ifile ${tmpout}2 && cat $tmpout >>${tmpout}2 } } &&
- cp ${tmpout}2 $ifile && rm -f ${tmpout}2; then
+/^[ ]*$startline/,/^[ ]*$endline/d" $ifile >>${tmpout}x } ||
+ { cp $ifile ${tmpout}x && cat $tmpout >>${tmpout}x } } &&
+ cp ${tmpout}x $ifile && rm -f ${tmpout}x; then
print "\nSuccessfully added compinstall lines to $ifile."
rm -f $tmpout
else
print "\nFailure adding lines to $ifile. Lines left in \`$tmpout'"
fi
- rm -f ${tmpout}2
+ rm -f ${tmpout}x
elif read -q key'?Print them to stdout instead ([y]es, [n]o)? '; then
cat $tmpout
rm -f $tmpout