mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
Fix regression in split_string_tok()
If there's no more separator we break early but dont update pos, so we go into the code path that asserts we have reached the limit.
This commit is contained in:
parent
fff8e8163b
commit
800f2414fb
2 changed files with 11 additions and 4 deletions
|
@ -349,10 +349,13 @@ pub fn split_string_tok<'val>(
|
||||||
let max_results = max_results.unwrap_or(usize::MAX);
|
let max_results = max_results.unwrap_or(usize::MAX);
|
||||||
while pos < end && out.len() + 1 < max_results {
|
while pos < end && out.len() + 1 < max_results {
|
||||||
// Skip leading seps.
|
// Skip leading seps.
|
||||||
pos += match val[pos..].iter().position(|c| !seps.contains(*c)) {
|
match val[pos..].iter().position(|c| !seps.contains(*c)) {
|
||||||
Some(p) => p,
|
Some(p) => pos += p,
|
||||||
None => break,
|
None => {
|
||||||
};
|
pos = end;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find next sep.
|
// Find next sep.
|
||||||
let next_sep = val[pos..]
|
let next_sep = val[pos..]
|
||||||
|
|
|
@ -389,3 +389,7 @@ echo foo | read status
|
||||||
# CHECKERR: (Type 'help read' for related documentation)
|
# CHECKERR: (Type 'help read' for related documentation)
|
||||||
echo read $status
|
echo read $status
|
||||||
# CHECK: read 2
|
# CHECK: read 2
|
||||||
|
|
||||||
|
echo ' foo' | read -n 1 -la var
|
||||||
|
set -S var
|
||||||
|
#CHECK: $var: set in local scope, unexported, with 0 elements
|
||||||
|
|
Loading…
Reference in a new issue