Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Bug in Functions/Misc/regexp-replace



Hello,

I think I found a bug in Functions/Misc/regexp-replace

Steps to reproduce:

zsh -f
str='x :=bad' 
autoload regexp-replace
regexp-replace str 'a' 'z' && echo $str

Actual Output:
(eval):1: bzd not found

Expected:
x :=bzd

Root cause:
Line 41: eval ${1}=${(q)5}
It appears the ${(q)5} is not escaping = so the =command is executed after :

Instead of 'x\ :\=bad', you get '= x\ :=bad'

One way to fix:
41: eval ${1}=${(qqq)5}

Patch file is attached.

Thanks
Jacob Menke

diff --git a/Functions/Misc/regexp-replace b/Functions/Misc/regexp-replace
index dec10552..4774444d 100644
--- a/Functions/Misc/regexp-replace
+++ b/Functions/Misc/regexp-replace
@@ -38,6 +38,6 @@ while [[ -n $4 ]]; do
 done
 5+=$4
 
-eval ${1}=${(q)5}
+eval ${1}=${(qqq)5}
 # status 0 if we did something, else 1.
 [[ -n $6 ]]


Messages sorted by: Reverse Date, Date, Thread, Author