-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
${parameter//“”/string} does not work correctly with multibyte string #813
Comments
Thanks for the report!
Testing my stash of compiled commits shows that the bug was introduced in commit ceae1e4. edit: Actually, it doesn't work at all in 93u+ and ksh2020, it has no effect, but at least it doesn't output invalid characters. |
diff --git a/src/cmd/ksh93/sh/macro.c b/src/cmd/ksh93/sh/macro.c
index c99ac5719..757ea2d9b 100644
--- a/src/cmd/ksh93/sh/macro.c
+++ b/src/cmd/ksh93/sh/macro.c
@@ -1916,7 +1916,7 @@ retry2:
flag & STR_MAXIMAL);
else
nmatch = strngrpmatch(v, vsize,
- *pattern ? pattern : "~(E)^",
+ *pattern || (flag & STR_MAXIMAL) ? pattern : "~(E)^",
(ssize_t*)match,
elementsof(match) / 2,
flag | STR_INT); |
However, that fix just masks a bug in the libast regex code, which can also be triggered in the AT&T versions, like so:
|
I don't mind about reverting back to the original behavior. I was wondering if this might be a feature. I was wondering about the behavior of an empty string in a pattern, so I looked up the behavior of other languages (e.g., replaceAll, replaceFirst).Some languages, such as JavaScript and Ruby, seem to insert a character between characters (but also at the end). Frankly, I find these specifications counter-intuitive. Python does not seem to accept empty characters. Since there is no pattern to replace, it is a reasonable enough behavior that nothing changes. |
The text was updated successfully, but these errors were encountered: