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

18512, modified: fix up for ${foo/\//stuf} fix

This commit is contained in:
Peter Stephenson 2003-05-12 10:55:21 +00:00
parent 6e77f38b92
commit 11cd9b2de3
6 changed files with 37 additions and 10 deletions

View file

@ -1,3 +1,12 @@
2003-05-08 Peter Stephenson <pws@csr.com>
* 18512 (modified for 4.0): README, Completion/Unix/Command/_cvs,
Completion/Unix/Command/_rsync, Completion/Unix/Type/_path_files,
Doc/Zsh/expn.yo: 18508 wasn't enough; the \\/ hack was documented
and in use in the completion system. Change the documentation,
mention the inconsistency in README and alter the completion
system to hide the `/' a parameter so that it doesn't care.
2003-05-07 Peter Stephenson <pws@csr.com>
* 18508: Src/subst.c, Test/D04parameter.ztst: quoting of the `/'

View file

@ -611,7 +611,7 @@ _cvs_loadstat () {
(( $+functions[_cvs_root] )) ||
_cvs_root () {
local cvspassfile id
local cvspassfile id slash
typeset -gU _cvs_roots
@ -622,7 +622,8 @@ _cvs_root () {
id="$(LC_ALL=C ls -l "$cvspassfile")"
fi
if [[ "$id" != "$_cvs_pass_id" ]]; then
_cvs_roots=($_cvs_roots ${${${${(f)"$(<$cvspassfile)"}#/1 }%% *}/:2401\\//:/})
slash=/
_cvs_roots=($_cvs_roots ${${${${(f)"$(<$cvspassfile)"}#/1 }%% *}/:2401${slash}/:/})
_cvs_pass_id="$id"
fi
fi
@ -918,13 +919,13 @@ _cvs_existing_entries () {
(( $+functions[_cvs_modified_entries] )) ||
_cvs_modified_entries () {
if _cvs_loadstat; then
local expl match linedir realdir pat
local expl match linedir realdir pat slash=/
match=()
: ${PREFIX:#(#b)(*/)(*)}
linedir="$match[1]"
realdir=${(e)~linedir}
[[ -f "$realdir"CVS/Entries ]] &&
[[ -n ${pat::="${(@j:|:)${(@)${(@)${(@)${(@)${(@)${(@M)${(@f)"$(<"$realdir"CVS/Entries)"}:#/*}#/}/\\/[^\\/]#\\///}%/[^/]#/[^/]#}:#${(j:|:)~${${${${(f)"$(LC_ALL=C builtin stat -gn +mtime -F '%a %b %e %T %Y' ${realdir}*(D) 2>/dev/null)"}##*/}/ //}//(#m)[][*?()<|^~#\\]/\\$MATCH}}}%%/*}//(#m)[][*?()<|^~#\\]/\\$MATCH}"} ]] &&
[[ -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"
else
_cvs_existing_entries

View file

@ -31,13 +31,14 @@ elif [[ -prefix 1 *:: ]]; then
_describe "remote modules" remmodules -S/
elif [[ -prefix 1 *: ]]; then
local remfiles remdispf remdispd
local remfiles remdispf remdispd slash
compset -P 1 '*:'
if zstyle -T ":completion:${curcontext}:" remote-access; then
slash=/
remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${${${words[CURRENT
]#*:}:h}/\\/(#e)/}/\* 2>/dev/null)"})
]#*:}:h}/${slash}(#e)/}/\* 2>/dev/null)"})
remdispf=(${remfiles:#*/})
remdispd=(${(M)remfiles:#*/})
@ -46,7 +47,7 @@ elif [[ -prefix 1 *: ]]; then
compadd -d remdispf ${${remfiles:#*/}/[*=@|](#e)/}
_wanted files expl 'remote files and directories' \
compadd -S/ -d remdispd ${${(M)remfiles:#*/}/\\/(#e)/}
compadd -S/ -d remdispd ${${(M)remfiles:#*/}/${slash}(#e)/}
else
_message 'remote files'
fi

View file

@ -204,7 +204,8 @@ if [[ "$pre" = [^][*?#^\|\<\>]#(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \' ]
eval 'realpath=${(e)~linepath}' 2>/dev/null
[[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1
pre="${pre#${linepath}}"
i="${#linepath//[^\\/]}"
i='[^/]'
i="${#linepath//$i}"
orig="${orig[1,(in:i:)/][1,-2]}"
donepath=
prepaths=( '' )

View file

@ -483,8 +483,8 @@ The var(pattern) may begin with a `tt(#)', in which case the
var(pattern) must match at the start of the string, or `tt(%)', in
which case it must match at the end of the string. The var(repl) may
be an empty string, in which case the final `tt(/)' may also be omitted.
To quote the final `tt(/)' in other cases it should be preceded by two
backslashes (i.e., a quoted backslash); this is not necessary if the
To quote the final `tt(/)' in other cases it should be preceded by a
single backslash; this is not necessary if the
`tt(/)' occurs inside a substituted parameter. Note also that the `tt(#)'
and `tt(%)' are not active if they occur inside a substituted parameter,
even at the start.

15
README
View file

@ -24,6 +24,21 @@ details, see the documentation.
Possible incompatibilities
---------------------------
A change between 4.0.6 and 4.0.7 affects substitutions of the form
${foo/src/rep} and ${foo//src/rep}. In 4.0.6, a literal `/' was quoted in
the `src' text with two backslashes. This was documented, but inconsistent
with normal quoting conventions and poorly implemented. The `/' now
requires only one backslash to quote it whether or not the expresion occurs
in double quotes. For example:
% foo=word/bird
% print ${foo/\//-} "${foo/\//+}"
word-bird word+bird
Note also the following workaround which is valid in all versions of the
shell that support this syntax:
% slash=/
% foo=word/bird
% print ${foo/$slash/-} "${foo/$slash/+}"
Some particular differences you may notice between version 3.0 and 4.0
(mostly based on 3.0.8; there are other differences from earlier versions):