Merge pull request #737 from JonnyWalker81/fix-last-command-crash

Fixed last command crash
This commit is contained in:
Jonathan Turner 2019-09-30 18:13:34 +13:00 committed by GitHub
commit af8e2f6961
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,10 +38,13 @@ fn last(
) -> Result<OutputStream, ShellError> {
let stream = async_stream! {
let v: Vec<_> = context.input.into_vec().await;
let k = v.len() - (*amount as usize);
for x in v[k..].iter() {
let y: Tagged<Value> = x.clone();
yield ReturnSuccess::value(y)
let count = (*amount as usize);
if count < v.len() {
let k = v.len() - count;
for x in v[k..].iter() {
let y: Tagged<Value> = x.clone();
yield ReturnSuccess::value(y)
}
}
};
Ok(stream.to_output_stream())