You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
first and take do the wrong thing for list<binary> input #7121
I think to add to that I think the behavior on other non list types is surprising:
> "hello world" | take 5
╭───┬─────────────╮
│ 0 │ hello world │
╰───┴─────────────╯
> 1 | take 3
╭───┬───╮
│ 0 │ 1 │
╰───┴───╯
My instinct would be that the true scalar might want to error (we should nevertheless provide a convenient way to coerce unknown input (either scalar or list) to a list)
With the string I might expect a substring or coercion to a list of chars.
The current behavior for binary landed with nushell/engine-q#284 into engine-q nushell. I haven't checked into the pre 0.59 history.
One use case I want to be sure not to lose is something like this, that I use ofter to look at BOMs in files.
open /etc/passwd | into binary | take 100
Length: 100 (0x64) bytes | printable whitespace ascii_other non_ascii
00000000: 23 23 0a 23 20 55 73 65 72 20 44 61 74 61 62 61 ##_# User Databa
00000010: 73 65 0a 23 20 0a 23 20 4e 6f 74 65 20 74 68 61 se_# _# Note tha
00000020: 74 20 74 68 69 73 20 66 69 6c 65 20 69 73 20 63 t this file is c
00000030: 6f 6e 73 75 6c 74 65 64 20 64 69 72 65 63 74 6c onsulted directl
00000040: 79 20 6f 6e 6c 79 20 77 68 65 6e 20 74 68 65 20 y only when the
00000050: 73 79 73 74 65 6d 20 69 73 20 72 75 6e 6e 69 6e system is runnin
00000060: 67 0a 23 20 g_#
Not that there's a BOM in the password file but the point is to be able to open any file, whether it's binary or text, and look at the first X bytes for deeper analysis.
Activity
sholderbach commentedon Nov 12, 2022
I think to add to that I think the behavior on other non
listtypes is surprising:My instinct would be that the true scalar might want to error (we should nevertheless provide a convenient way to coerce unknown input (either scalar or list) to a list)
With the string I might expect a substring or coercion to a list of chars.
The current behavior for binary landed with nushell/engine-q#284 into engine-q nushell. I haven't checked into the pre 0.59 history.
rgwood commentedon Nov 12, 2022
Agreed that the behaviour for other types is surprising. Related: #6941
I'm working on cleaning some of this up for
firstandtakeand it is turning into a yak shave. Will see how far I get.fdncred commentedon Nov 12, 2022
One use case I want to be sure not to lose is something like this, that I use ofter to look at BOMs in files.
Not that there's a BOM in the password file but the point is to be able to open any file, whether it's binary or text, and look at the first X bytes for deeper analysis.
rgwood commentedon Nov 12, 2022
For sure, I'm planning to keep the binary -> binary functionality as-is.