-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ranges and str substring
are inconsistent (off by 1)
#7761
Closed
Labels
inconsistent-behavior
Behavior between different commands or types inconsistent/unexpected
Milestone
Comments
sholderbach
added
the
inconsistent-behavior
Behavior between different commands or types inconsistent/unexpected
label
Jan 15, 2023
Hey, could you assign me this issue? If I understood it correctly, the inconsistency should be resolved by having something like this:
|
While you're at it, could you make |
yes, definitely |
@MehulG Let us know if you're still interested in this one. |
@MehulG Were you going to work in this? |
This was referenced May 17, 2024
kubouch
pushed a commit
that referenced
this issue
May 22, 2024
…2894) # Description Fixes: #7761 It's still unsure if we want to change the `range semantic` itself, but it's good to keep range semantic consistent between nushell commands. # User-Facing Changes ### Before ```nushell ❯ "abc" | str substring 1..=2 b ``` ### After ```nushell ❯ "abc" | str substring 1..=2 bc ``` # Tests + Formatting Adjust tests to fit new behavior
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
1..3
produces 3 numbers:str substring 1..3
produces 2 characters:That's an unpleasant inconsistency.
How to reproduce
Use
str substring
with a range, observe that it produces 1 fewer character than there are numbers in the range.Expected behavior
I expect that a range with
n
numbers should produce a string ofn
characters when used withstr substring
.Screenshots
No response
Configuration
Additional context
No response
The text was updated successfully, but these errors were encountered: