Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix #2859; script error when cwd name contains%#2861

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@chrisant996
Copy link
Contributor

Thestring.gsub() function in Lua always uses Lua patterns (which are similar to regular expressions). Cmder's custom prompt wants to perform simple plain text find/replace operations on strings.string.gsub() is the right Lua function for that, but since it always uses Lua patterns it's necessary to apply escaping to the input strings otherwise they can get misinterpreted and cause runtime errors.

For example, if the current working directory name contains a percent sign, such as literally "My%20Home".

This change fixes that. It introduces a helper functiongsub_plain() which behaves likestring.gsub() but applies appropriate escaping to convert the plain text input strings into the corresponding Lua patterns so that it can achieve plain text find/replace operations.

It also introduces separate helper functions for escaping thefind andreplace parameters forstring.gsub(), since they have different escaping rules.

DRSDavidSoft reacted with heart emoji
The `string.gsub()` function in Lua always uses Lua patterns (which aresimilar to regular expressions).  Cmder's custom prompt wants to performsimple plain text find/replace operations on strings.  `string.gsub()`is the right Lua function for that, but since it always uses Luapatterns it's necessary to apply escaping to the input strings otherwisethey can get misinterpreted and cause runtime errors.For example, if the current working directory name contains a percentsign, such as literally "My%20Home".This change fixes that.  It introduces a helper function `gsub_plain()`which behaves like `string.gsub()` but applies appropriate escaping toconvert the plain text input strings into the corresponding Luapatterns so that it can achieve plain text find/replace operations.It also introduces separate helper functions for escaping the `find` and`replace` parameters for `string.gsub()`, since they have differentescaping rules.
@chrisant996chrisant996 mentioned this pull requestJul 12, 2023
@DRSDavidSoftDRSDavidSoft self-assigned thisJul 16, 2023
@DRSDavidSoftDRSDavidSoft merged commit3ea9728 intocmderdev:masterJul 25, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

@DRSDavidSoftDRSDavidSoft

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@chrisant996@DRSDavidSoft

[8]ページ先頭

©2009-2025 Movatter.jp