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

Re: Bug in Functions/Misc/regexp-replace



On Thu, Apr 29, 2021 at 07:53:52PM -0400, Jacob Menke wrote:
> Hello,
> 
> I think I found a bug in Functions/Misc/regexp-replace

> One way to fix:
> 41: eval ${1}=${(qqq)5}
> 
> Patch file is attached.

Thanks for the report, minimal reproducer, and patch. I think it would
make sense to swap the eval for ${(P) ::= here as below.


diff --git a/Functions/Misc/regexp-replace b/Functions/Misc/regexp-replace
index dec105524..ff82c39b6 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}
+: ${(P)1::=$5}
 # status 0 if we did something, else 1.
 [[ -n $6 ]]




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