-
Notifications
You must be signed in to change notification settings - Fork 2.1k
str replace should use plain string by default #8037
Copy link
Copy link
Closed
Labels
polishthis problem makes nu feel unpolishedthis problem makes nu feel unpolishedsemanticsPlaces where we should define/clarify nushell's semanticsPlaces where we should define/clarify nushell's semantics
Description
Describe the bug
Currently, str replace uses regex by default which might be surprising, e.g., on Windows in cases like 'C:\Users\kubouch' | str replace 'C:\Users' 'foo'.
How to reproduce
> 'C:\Users\kubouch' | str replace 'C:\Users' 'foo'
Error: nu::shell::unsupported_input (link)
× Unsupported input
╭─[entry #4:1:1]
1 │ 'C:\Users\kubouch' | str replace 'C:\Users' 'foo'
· ─────┬───── ─────┬────
· │ ╰── input type: value originates from here
· ╰── Parsing error at position 4: Invalid hex escape
╰────
Expected behavior
foo\kubouch
The solution is to use the --string flag but I think it should be the other way: String by default and regex with --regex flag
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.75.1 |
| branch | main |
| commit_hash | f4bd78b |
| build_os | windows-x86_64 |
| build_target | x86_64-pc-windows-msvc |
| rust_version | rustc 1.66.1 (90743e729 2023-01-10) |
| rust_channel | 1.66.1-x86_64-pc-windows-msvc |
| cargo_version | cargo 1.66.1 (ad779e08b 2023-01-10) |
| pkg_version | 0.75.1 |
| build_time | 2023-02-11 12:40:58 +02:00 |
| build_rust_channel | release |
| features | database, dataframe, default, trash, which, zip |
| installed_plugins |
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
polishthis problem makes nu feel unpolishedthis problem makes nu feel unpolishedsemanticsPlaces where we should define/clarify nushell's semanticsPlaces where we should define/clarify nushell's semantics