You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
0.94.x str substring regression with negative end-offset #13077
I had a long-running process that was still running under my previous 0.93 release that I just stopped and reloaded in 0.94.2 where it promptly crashed. I've isolated the problem to str substring no longer properly handling negative offsets from the end of a string.
(-2) as the end-offset now works like (-1) used to under 0.93.
>"apples"|str substring0..(-2)
apple
cc @WindSoilder - I've bisected this to #12894. I don't see any mention of negative offsets in that PR. Was this an intentional part of the change or no?
It seems to me that -1 more accurately reflects "one character before the end of the string" in a slicing operation? It also seems to me that using an end-offset of -1 shouldn't result in an empty string?
Related (and starting to understand the "consistency" issues a bit ...):
Activity
WindSoilder commentedon Jun 8, 2024
I think
-1should be the last character of string. Soare work as expected. And then
"apples" | str substring 0..(-1)should returnapples, and"apples" | str substring 0..(-2)should returnappleImproves commands that support range input (nushell#13113)