mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-19 06:31:13 -03:00
builtin set: fix regression in error message description
(cherry picked from commit ab3c932903)
This commit is contained in:
@@ -468,7 +468,7 @@ fn split_var_and_indexes_internal<'a>(
|
||||
l_ind = 1; // first index
|
||||
} else {
|
||||
l_ind = wcstoi_partial(c, crate::wutil::Options::default(), &mut consumed)
|
||||
.map_err(|_| EnvArrayParseError::InvalidIndex(res.varname.to_owned()))?;
|
||||
.map_err(|_| EnvArrayParseError::InvalidIndex(c.slice_from(consumed).to_owned()))?;
|
||||
c = c.slice_from(consumed);
|
||||
// Skip trailing whitespace.
|
||||
while !c.is_empty() && c.char_at(0).is_whitespace() {
|
||||
@@ -494,11 +494,14 @@ fn split_var_and_indexes_internal<'a>(
|
||||
let l_ind2: isize;
|
||||
// If we are at the last index range expression, a missing end-index means the range
|
||||
// spans until the last item.
|
||||
let tmp = consumed;
|
||||
if res.indexes.is_empty() && c.char_at(0) == ']' {
|
||||
l_ind2 = -1;
|
||||
} else {
|
||||
l_ind2 = wcstoi_partial(c, crate::wutil::Options::default(), &mut consumed)
|
||||
.map_err(|_| EnvArrayParseError::InvalidIndex(res.varname.to_owned()))?;
|
||||
.map_err(|_| {
|
||||
EnvArrayParseError::InvalidIndex(c.slice_from(consumed - tmp).to_owned())
|
||||
})?;
|
||||
c = c.slice_from(consumed);
|
||||
// Skip trailing whitespace.
|
||||
while !c.is_empty() && c.char_at(0).is_whitespace() {
|
||||
|
||||
@@ -951,12 +951,19 @@ while set -e undefined
|
||||
end
|
||||
|
||||
set -e undefined[x..]
|
||||
# CHECKERR: set: Invalid index starting at 'undefined'
|
||||
# CHECKERR: set: Invalid index starting at 'x..]'
|
||||
# CHECKERR: {{.*}}checks/set.fish (line {{\d+}}):
|
||||
# CHECKERR: set -e undefined[x..]
|
||||
# CHECKERR: ^
|
||||
# CHECKERR: (Type 'help set' for related documentation)
|
||||
|
||||
set -e undefined[..y]
|
||||
# CHECKERR: set: Invalid index starting at 'y]'
|
||||
# CHECKERR: {{.*}}checks/set.fish (line {{\d+}}):
|
||||
# CHECKERR: set -e undefined[..y]
|
||||
# CHECKERR: ^
|
||||
# CHECKERR: (Type 'help set' for related documentation)
|
||||
|
||||
set -e undefined[1..]
|
||||
set -e undefined[..]
|
||||
set -e undefined[..1]
|
||||
|
||||
Reference in New Issue
Block a user