cvs commit completion doesn't work on file names containing spaces, while cvs status completion does. hugo@jibboom ~/foo% ls CVS/ foo bar.eee When trying to complete cvs status, I get as expected: hugo@jibboom ~/foo% cvs status <TAB> CVS/ foo\ bar.eee However, for cvs commit: hugo@jibboom ~/foo% cvs commit <TAB> foo bar.eee If I hit <TAB> again: hugo@jibboom ~/foo% cvs commit foo and then: hugo@jibboom ~/foo% cvs commit bar.eee Regards, Hugo
_cvs_modified_entries() doesn't like filenames with spaces.
On Jun 21, 1:50pm, Clint Adams wrote:
}
} _cvs_modified_entries() doesn't like filenames with spaces.
That's almost certainly because it's calling "builtin stat" and then
parsing the output with the World's Hairiest Parameter Substitution (TM).
Which is pretty silly given that stat can assign directly to an array
without the need to fork a $(...) substitution.
See if this isn't better. The substitution isn't that much less hairy,
but it doesn't fork and it doesn't depend on splitting on spaces.
Index: Src/_cvs
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Completion/Unix/Command/_cvs,v
retrieving revision 1.17
diff -c -r1.17 _cvs
--- Src/_cvs 28 May 2005 04:32:46 -0000 1.17
+++ Src/_cvs 22 Jun 2005 00:53:00 -0000
@@ -868,8 +868,11 @@
: ${PREFIX:#(#b)(*/)(*)}
linedir="$match[1]"
realdir=${(e)~linedir}
- [[ -f "$realdir"CVS/Entries ]] &&
- [[ -n ${pat::="${(@j:|:)${(@)${(@)${(@)${(@)${(@)${(@M)${(@f)"$(<"$realdir"CVS/Entries)"}:#/*}#/}/${slash}[^${slash}]#${slash}//}%/[^/]#/[^/]#}:#${(j:|:)~${${${${(f)"$(LC_ALL=C builtin stat -gn +mtime -F '%a %b %e %T %Y' ${realdir}*(D) 2>/dev/null)"}##*/}/ //}//(#m)[][*?()<|^~#\\]/\\$MATCH}}}%%/*}//(#m)[][*?()<|^~#\\]/\\$MATCH}"} ]] &&
+ [[ -f "$realdir"CVS/Entries ]] && {
+ local -a mtime
+ LC_ALL=C builtin stat -A mtime -gn +mtime -F $'%a %b %e %T %Y\n' ${realdir}*(D) 2>/dev/null
+ [[ -n ${pat::="${(@j:|:)${(@)${(@)${(@)${(@)${(@)${(@M)${(@f)"$(<"$realdir"CVS/Entries)"}:#/*}#/}/${slash}[^${slash}]#${slash}//}%/[^/]#/[^/]#}:#${(j:|:)~${(f)${(j:/:)${mtime##*/}}//(#m)[][*?()<|^~#\\]/\\$MATCH}#/}}%%/*}//(#m)[][*?()<|^~#\\]/\\$MATCH}"} ]]
+ } &&
_wanted files expl 'modified file' _path_files -g "$pat"
else
_cvs_existing_entries
spaces, so if one touches "blah argh" and "blah", and cvs add's them,
then cvs commit <TAB> will complete "blah" and "argh".
$pat will be something like "blah argh|blah"
Adding the parens makes it do the right thing in this particular case.
What's the correct fix?
Index: _cvs
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_cvs,v
retrieving revision 1.25
diff -u -r1.25 _cvs
--- _cvs 11 May 2005 09:27:10 -0000 1.25
+++ _cvs 22 Jun 2005 01:26:49 -0000
@@ -868,9 +868,12 @@
: ${PREFIX:#(#b)(*/)(*)}
linedir="$match[1]"
realdir=${(e)~linedir}
- [[ -f "$realdir"CVS/Entries ]] &&
- [[ -n ${pat::="${(@j:|:)${(@)${(@)${(@)${(@)${(@)${(@M)${(@f)"$(<"$realdir"CVS/Entries)"}:#/*}#/}/${slash}[^${slash}]#${slash}//}%/[^/]#/[^/]#}:#${(j:|:)~${${${${(f)"$(LC_ALL=C builtin stat -gn +mtime -F '%a %b %e %T %Y' ${realdir}*(D) 2>/dev/null)"}##*/}/ //}//(#m)[][*?()<|^~#\\]/\\$MATCH}}}%%/*}//(#m)[][*?()<|^~#\\]/\\$MATCH}"} ]] &&
- _wanted files expl 'modified file' _path_files -g "$pat"
+ [[ -f "$realdir"CVS/Entries ]] && {
+ local -a mtime
+ LC_ALL=C builtin stat -A mtime -gn +mtime -F $'%a %b %e %T %Y\n' ${realdir}*(D) 2>/dev/null
+ [[ -n ${pat::="${(@j:|:)${(@)${(@)${(@)${(@)${(@)${(@M)${(@f)"$(<"$realdir"CVS/Entries)"}:#/*}#/}/${slash}[^${slash}]#${slash}//}%/[^/]#/[^/]#}:#${(j:|:)~${(f)${(j:/:)${mtime##*/}}//(#m)[][*?()<|^~#\\]/\\$MATCH}#/}}%%/*}//(#m)[][*?()<|^~#\\]/\\$MATCH}"} ]]
+ } &&
+ _wanted files expl 'modified file' _path_files -g "($pat)"
else
_cvs_existing_entries
fi
On Jun 21, 9:30pm, Clint Adams wrote: } Subject: Re: Bug#315255: zsh: cvs commit completion breaks on spaces } } Adding the parens makes it do the right thing in this particular case. I'm concerned that the parens will be confused for a glob qualifier if there is only one possible match. If that doesn't happen, then this would be OK. } What's the correct fix? I would have expected _path_files to do the right thing, so maybe the fix is somewhere there. Or might it be _wanted ...?