mirror of
https://github.com/nushell/nushell.git
synced 2024-12-24 16:09:11 +01:00
Merge pull request #737 from JonnyWalker81/fix-last-command-crash
Fixed last command crash
This commit is contained in:
commit
af8e2f6961
@ -38,11 +38,14 @@ fn last(
|
|||||||
) -> Result<OutputStream, ShellError> {
|
) -> Result<OutputStream, ShellError> {
|
||||||
let stream = async_stream! {
|
let stream = async_stream! {
|
||||||
let v: Vec<_> = context.input.into_vec().await;
|
let v: Vec<_> = context.input.into_vec().await;
|
||||||
let k = v.len() - (*amount as usize);
|
let count = (*amount as usize);
|
||||||
|
if count < v.len() {
|
||||||
|
let k = v.len() - count;
|
||||||
for x in v[k..].iter() {
|
for x in v[k..].iter() {
|
||||||
let y: Tagged<Value> = x.clone();
|
let y: Tagged<Value> = x.clone();
|
||||||
yield ReturnSuccess::value(y)
|
yield ReturnSuccess::value(y)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Ok(stream.to_output_stream())
|
Ok(stream.to_output_stream())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user