forked from extern/nushell
Implementing ByteStream interuption on infinite stream (#13552)
# Description This PR should address #13530 by explicitly handling ByteStreams. The issue can be replicated easily on linux by running: ```nushell open /dev/urandom | into binary | bytes at ..10 ``` Would leave the output hanging and with no way to cancel it, this was likely because it was trying to collect the input stream and would not complete. I have also put in an error to say that using negative offsets for a bytestream without a length cannot be used. ```nushell ~/git/nushell> open /dev/urandom | into binary | bytes at (-1).. Error: nu:🐚:incorrect_value × Incorrect value. ╭─[entry #3:1:35] 1 │ open /dev/urandom | into binary | bytes at (-1).. · ────┬─── ───┬── · │ ╰── encountered here · ╰── Negative range values cannot be used with streams that don't specify a length ╰──── ``` # User-Facing Changes No operation changes, only the warning you get back for negative offsets # Tests + Formatting Ran `toolkit check pr ` with no errors or warnings Manual testing of the example commands above --------- Co-authored-by: Ian Manske <ian.manske@pm.me> Co-authored-by: Simon Curtis <simon.curtis@candc-uk.com>
This commit is contained in:
@ -653,6 +653,18 @@ pub enum ShellError {
|
||||
creation_site: Span,
|
||||
},
|
||||
|
||||
/// Attempted to us a relative range on an infinite stream
|
||||
///
|
||||
/// ## Resolution
|
||||
///
|
||||
/// Ensure that either the range is absolute or the stream has a known length.
|
||||
#[error("Relative range values cannot be used with streams that don't have a known length")]
|
||||
#[diagnostic(code(nu::shell::relative_range_on_infinite_stream))]
|
||||
RelativeRangeOnInfiniteStream {
|
||||
#[label = "Relative range values cannot be used with streams that don't have a known length"]
|
||||
span: Span,
|
||||
},
|
||||
|
||||
/// An error happened while performing an external command.
|
||||
///
|
||||
/// ## Resolution
|
||||
|
Reference in New Issue
Block a user