mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 14:17:46 +02:00
Allow byte streams with unknown type to be compatiable with binary (#12959)
# Description Currently, this pipeline doesn't work `open --raw file | take 100`, since the type of the byte stream is `Unknown`, but `take` expects `Binary` streams. This PR changes commands that expect `ByteStreamType::Binary` to also work with `ByteStreamType::Unknown`. This was done by adding two new methods to `ByteStreamType`: `is_binary_coercible` and `is_string_coercible`. These return true if the type is `Unknown` or matches the type in the method name.
This commit is contained in:
@ -160,7 +160,7 @@ fn string_helper(
|
||||
// Just set the type - that should be good enough. There is no guarantee that the data
|
||||
// within a string stream is actually valid UTF-8. But refuse to do it if it was already set
|
||||
// to binary
|
||||
if stream.type_() != ByteStreamType::Binary {
|
||||
if stream.type_().is_string_coercible() {
|
||||
Ok(PipelineData::ByteStream(
|
||||
stream.with_type(ByteStreamType::String),
|
||||
metadata,
|
||||
|
Reference in New Issue
Block a user