Change str replace to match substring by default#10038
Conversation
|
100% agree that dealing with Windows paths is a huge pain because of escaping. |
amtoine
left a comment
There was a problem hiding this comment.
this looks good and sensible to me 👍
|
I had to change statements like this let home = ($nu.home-path | str replace -a '\\' '/')to this let home = ($nu.home-path | str replace -a '\' '/')or let home = ($nu.home-path | str replace -ar '\\' '/')This is going to break a bunch of stuff since things work differently now. 82 occurrences in nu_scripts. I guess it's not really deprecated since it doesn't work the way it used to? |
|
Yeah, it's a breaking change. Not sure how to avoid that. If we added only the warning for |
fdncred
left a comment
There was a problem hiding this comment.
I'm fine with moving forward with this because it makes str replace more consistent with the other commands that use regular expression parameters. However, we should be prepared for a fairly significant breaking change. str replace is used all over the place.
|
OK, let's try. |
|
this also makes it more consistent with other commands such as |
related to nushell/nushell/pull/10038
related to nushell/nushell/pull/10038 commands used ```nushell sd "str replace (.*) --string" "str FOO replace $1" **/*.nu sd "str replace" "str replace --regex" **/*.nu sd "str FOO replace" "str replace" **/*.nu ```
|
@kubouch sd "str replace (.*) --string" "str FOO replace $1" **/*.nu
sd "str replace" "str replace --regex" **/*.nu
sd "str FOO replace" "str replace" **/*.nuto fix the two repos where i had i think this is worth putting in the release notes 😋 |
related to nushell/nushell/pull/10038 commands used ```nushell sd "str replace (.*) --string" "str FOO replace $1" **/*.nu sd "str replace" "str replace --regex" **/*.nu sd "str FOO replace" "str replace" **/*.nu ```
|
@amtoine I'm not a big fan of pointing people to other tools if nushell can do the same thing via a pipeline. Granted, sd is meant for this singular purpose. |
regardless of the tool, i think we should give some commands for folks to fix their scripts and config 😋 |
|
What I did was replace |
related to - #10038 # Description `str replace --string` has been deprecated in #10038 and should be removed before 0.85. this PR removes the `--string` option from `str replace` completely. # User-Facing Changes `str replace --string` will no longer work and will give an error instead of a warning.
related to - nushell#10038 # Description `str replace --string` has been deprecated in nushell#10038 and should be removed before 0.85. this PR removes the `--string` option from `str replace` completely. # User-Facing Changes `str replace --string` will no longer work and will give an error instead of a warning.
related to - nushell#10038 # Description `str replace --string` has been deprecated in nushell#10038 and should be removed before 0.85. this PR removes the `--string` option from `str replace` completely. # User-Facing Changes `str replace --string` will no longer work and will give an error instead of a warning.




Description
This PR makes
str replaceto match substring by default instead of regular expression. I was constantly getting tripped over this when usingstr replaceon Windows paths which got interpreted as escape characters.User-Facing Changes
str replace --string(this is now the default behavior)--regexflag. (--multilineflag implies--regex)Tests + Formatting
After Submitting