mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-10 12:40:58 +02:00
12076: better saving in file in compinstall
This commit is contained in:
parent
8d0feb4b31
commit
29030cc13b
2 changed files with 23 additions and 14 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2000-06-26 Peter Stephenson <pws@cambridgesiliconradio.com>
|
||||||
|
|
||||||
|
* 12076: Completion/Core/compinstall: overwrote file if no
|
||||||
|
style information; overwrote symbolic link instead of following;
|
||||||
|
didn't check file name for sanity.
|
||||||
|
|
||||||
2000-06-26 Bart Schaefer <schaefer@zsh.org>
|
2000-06-26 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
* 12074: Doc/Zsh/builtins.yo, Doc/Zsh/manual.yo: Remove one more
|
* 12074: Doc/Zsh/builtins.yo, Doc/Zsh/manual.yo: Remove one more
|
||||||
|
|
|
@ -35,7 +35,7 @@ integer lines_found
|
||||||
#
|
#
|
||||||
# This relies on the stuff we find being only minimally edited from
|
# This relies on the stuff we find being only minimally edited from
|
||||||
# the stuff we originally saved. A better way of doing this would
|
# the stuff we originally saved. A better way of doing this would
|
||||||
# almost certianly be to use the style mechanism directly: save the
|
# almost certainly be to use the style mechanism directly: save the
|
||||||
# current styles in a variable, delete all styles, read in and evaluate
|
# current styles in a variable, delete all styles, read in and evaluate
|
||||||
# any styles found, manipulate styles directly using zstyle, write out
|
# any styles found, manipulate styles directly using zstyle, write out
|
||||||
# using zstyle -L, and if necessary restore the original styles. One
|
# using zstyle -L, and if necessary restore the original styles. One
|
||||||
|
@ -147,17 +147,19 @@ elif [[ -n $warn_comment ]]; then
|
||||||
print "All the comments in your configuration section will be lost.
|
print "All the comments in your configuration section will be lost.
|
||||||
If you want to keep them, you should copy them somewhere else first."
|
If you want to keep them, you should copy them somewhere else first."
|
||||||
elif (( ! $lines_found )); then
|
elif (( ! $lines_found )); then
|
||||||
print -n "Starting a new completion configuration from scratch.
|
print "Starting a new completion configuration from scratch."
|
||||||
This will be "
|
if [[ -n $ifile && ! -d $ifile ]]; then
|
||||||
if [[ ! -f $ifile ]]; then
|
print -n "This will be "
|
||||||
print "written to the new file $ifile."
|
if [[ ! -f $ifile ]]; then
|
||||||
elif [[ ! -w $ifile ]]; then
|
print "written to the new file $ifile."
|
||||||
print "written to the file ~/.compinstall for copying to $ifile."
|
elif [[ ! -w $ifile ]]; then
|
||||||
ifile=$HOME/.compinstall
|
print "written to the file ~/.compinstall for copying to $ifile."
|
||||||
else
|
ifile=$HOME/.compinstall
|
||||||
print "appended to the file $ifile. It is up to you to ensure
|
else
|
||||||
|
print "appended to the file $ifile. It is up to you to ensure
|
||||||
that these lines are actually executed. They will not be if your .zshrc
|
that these lines are actually executed. They will not be if your .zshrc
|
||||||
usually returns before the end."
|
usually returns before the end."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
print "Note that you will be given a chance to save the new setup
|
print "Note that you will be given a chance to save the new setup
|
||||||
|
@ -1711,8 +1713,9 @@ zstyle ${(qq)stylevals[1]} $style $stylevals[2]"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! read -q key"?Save new settings to $ifile? "; then
|
if [[ -z $ifile || -d $ifile ]] ||
|
||||||
print "Enter a different filename (~ will be expanded), or return to abort:"
|
! read -q key"?Save new settings to $ifile? "; then
|
||||||
|
print "Enter file to save in (~ will be expanded), or return to abort:"
|
||||||
ifile=
|
ifile=
|
||||||
vared -ch -p 'file> ' ifile
|
vared -ch -p 'file> ' ifile
|
||||||
ifile=${~ifile}
|
ifile=${~ifile}
|
||||||
|
@ -1759,8 +1762,8 @@ future use."
|
||||||
if { { grep "$endline" $ifile >/dev/null 2>&1 &&
|
if { { grep "$endline" $ifile >/dev/null 2>&1 &&
|
||||||
sed -e "/^[ ]*$endline/r $tmpout
|
sed -e "/^[ ]*$endline/r $tmpout
|
||||||
/^[ ]*$startline/,/^[ ]*$endline/d" $ifile >${tmpout}2 } ||
|
/^[ ]*$startline/,/^[ ]*$endline/d" $ifile >${tmpout}2 } ||
|
||||||
cat $tmpout >>${tmpout}2 } &&
|
{ cp $ifile ${tmpout}2 && cat $tmpout >>${tmpout}2 } } &&
|
||||||
mv ${tmpout}2 $ifile; then
|
cp ${tmpout}2 $ifile && rm -f ${tmpout}2; then
|
||||||
print "\nSuccessfully added compinstall lines to $ifile."
|
print "\nSuccessfully added compinstall lines to $ifile."
|
||||||
rm -f $tmpout
|
rm -f $tmpout
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue