mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-28 17:10:59 +01:00
unposted: return status 1 if no replacement
This commit is contained in:
parent
7ec0c64b4d
commit
1c71dfd735
2 changed files with 12 additions and 1 deletions
|
|
@ -19,13 +19,19 @@ emulate -L zsh
|
|||
4=${(P)1}
|
||||
# $5 is the final string
|
||||
5=
|
||||
# 6 indicates if we made a change
|
||||
6=
|
||||
local MATCH MBEGIN MEND
|
||||
local -a match mbegin mend
|
||||
|
||||
while [[ -n $4 ]]; do
|
||||
if [[ $4 =~ $2 ]]; then
|
||||
# append initial part and subsituted match
|
||||
5+=${4[1,MBEGIN-1]}${(e)3}
|
||||
# truncate remaining string
|
||||
4=${4[MEND+1,-1]}
|
||||
# indicate we did something
|
||||
6=1
|
||||
else
|
||||
break
|
||||
fi
|
||||
|
|
@ -33,3 +39,5 @@ done
|
|||
5+=$4
|
||||
|
||||
eval ${1}=${(q)5}
|
||||
# status 0 if we did something, else 1.
|
||||
[[ -n $6 ]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue