Skip to content

first and take do the wrong thing for list<binary> input #7121

@rgwood

Description

@rgwood

Describe the bug

take n currently works like this:

  1. Peek at the first value in the input (important: this can either be the first value in a list or a scalar value passed as input)
  2. If that first value is a binary, return the first n bytes in that binary

This means that take cannot be used to get the first n binaries in a list<binary>. first is affected in much the same way.

How to reproduce

This returns the first byte of a binary:

〉0x[01 23] | take 1
Length: 1 (0x1) bytes | printable whitespace ascii_other non_ascii
00000000:   01

If we wrap the binary in a list, we get the exact same result:

〉[0x[01 23]] | take 1
Length: 1 (0x1) bytes | printable whitespace ascii_other non_ascii
00000000:   01

Expected behavior

[0x[01 23]] | take 1 should return 0x[01 23].

take and first should get the first binaries from a list<binary>, not the first bytes in the first element of the list.

Screenshots

No response

Configuration

key value
version 0.71.1
branch main
commit_hash 817eacc
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.63.0 (4b91a6ea7 2022-08-08)
rust_channel 1.63.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.63.0 (fd9c4297c 2022-07-01)
pkg_version 0.71.1
build_time 2022-11-11 22:41:27 -08:00
build_rust_channel debug
features default, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpected

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions