Repository navigation
Closed
Description
Describe the bug
I wanted to dump the first bytes of a PNG file using cat myimage.png | into binary -b 100 but got a table instead of a binary view.
To Reproduce
Steps to reproduce the behavior:
cat myimage.png | into binary -b 100
Expected behavior
I expected an output like this:
Length: 140 (0x8c) bytes | printable whitespace ascii_other non_ascii
00000000: ef bf bd 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 ×××PNG__•_000_IH
00000010: 44 52 00 00 07 76 00 00 04 18 08 06 00 00 00 ef DR00•v00••••000×
00000020: bf bd 2d 38 ef bf bd 00 00 00 09 70 48 59 73 00 ××-8×××000_pHYs0
00000030: 00 0e ef bf bd 00 00 0e ef bf bd 01 ef bf bd 2b 0•×××00•××ו×××+
00000040: 0e 1b 00 00 20 00 49 44 41 54 78 ef bf bd ef bf ••00 0IDATx×××××
00000050: bd ef bf bd 79 7c 14 ef bf bd ef bf bd ef bf bd ××××y|•×××××××××
00000060: ef bf bd ef bf bd 77 76 73 10 6e 0f 50 7b ef bf ××××××wvs•n•P{××
00000070: bd 55 10 ef bf bd 79 ef bf bd 1c 49 ef bf bd 20 ×U•×××y××וI×××
00000080: ef bf bd 72 58 2b 1a ef bf bd d5 aa ×××rX+•×××××
(I got this output using cat img.png | into binary -b 100 | nth 0 as suggested on Discord)
Configuration (please complete the following information):
Run version | pivot and paste the output to show OS, features, etc.
| Column0 | Column1 |
|---|---|
| version | 0.31.0 |
| short_commit | b93b80c |
| commit_hash | b93b80c |
| commit_date | 2021-05-11 07:59:24 |
| build_os | linux-x86_64 |
| rust_version | rustc 1.52.1 (9bc8c42bb 2021-05-09) |
| rust_channel | stable-x86_64-unknown-linux-gnu (default) |
| cargo_version | cargo 1.52.0 (69767412a 2021-04-21) |
| pkg_version | 0.31.0 |
| build_time | 2021-05-11 10:07:34 |
| build_rust_channel | release |
| features | clipboard-cli, ctrlc, default, directories, dirs, ptree, rustyline, term, trash, uuid, which, zip |
Metadata
Metadata
Assignees
Labels
No labels
Activity
sophiajt commentedon May 12, 2021
tagging @fdncred, who worked on this
fdncred commentedon May 12, 2021
it's because you're using

catinstead ofopen. I thoughtcatwas meant for text files. I've never tried to use it on binary files like a png file.I can't even do your workaround without it horking my screen and giving an error with cat, but i'm on windows so i'm sure things are handled differently there.
sophiajt commentedon May 12, 2021
@fdncred - I'm seeing the same issue with
open. It seems to be related to how big the binary is. If it's larger than 8k (our current packet size), theninto binarywill give back rows of binary rather than a hex output.agateau commentedon May 13, 2021
If I am not mistaken,
catdoes not care about the file content, it just sends bytes. For example what I tried to achieve can be done like this in a "traditional" unix shell:On the other hand, if the right way to do this with Nushell is through
openthat's OK too. Changing tools can require changing habits, butopenproduced strange results: It worked well with a 10.8MB jpeg but not with a 59.8MB mp4. Here is a transcript:sophiajt commentedon May 13, 2021
Seems like
into binaryis applying the same thing to every row instead of counting the total bytes and returning that many.github-actions commentedon Jun 24, 2021
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
github-actions commentedon Jul 8, 2021
This issue has been marked stale for more than 10 days without activity. Closing this issue, but if you find that the issue is still valid, please reopen.
fdncred commentedon Jul 8, 2021
I may work on this.