sharkdp / hexyl

A command-line hex viewer
Apache License 2.0
8.92k stars 227 forks source link

(Partial) compatibility with xxd? #121

Closed sharkdp closed 1 year ago

sharkdp commented 3 years ago

I think it would be interesting to try and maintain some level of compatibility with xxd. I recently came across this when following a blog post, trying to use hexyl instead of xxd.

What other flags/options could we try to support or try to provide aliases for?

What we're definitely not going to support is long single-dash options like -groupsize. Instead, we are always going to keep a style where long options come with two dashes --groupsize.

By the way, one thing that we already do better:

Even though xxd itself doesn't support hexadecimal notation […]

So instead of xxd -s $((0x2118)) ./hello we can simply say hexyl -s 0x2118 ./hello.

Note: we already try to be (partially) compatible with hexdump.

martinlindhe commented 2 years ago

Another xxd feature that I find is most lacking is -r (reverse hexdump). Using it you can convert a hexdump into a binary, like this:

xxd file > file.hex
cat file.hex | xxd -r > reconstructed-file
sharkdp commented 1 year ago

We now have a new --group-bytes option in hexyl which is basically the same as xxds -groupsize (?). @RinHizakura why did we call it like that.. and not --groupsize or at least --group-size?

RinHizakura commented 1 year ago

It is basically the same as -groupsize in xxd. Since I didn't aware of the requirement of compatibility, so the naming didn't align with xxd at that time. I think you could change --group-bytes to --groupsize directly if you like it.

sharkdp commented 1 year ago

I see, thanks. I believe we should change it to --groupsize then. At least as an alias. But I don't really see a reason to choose group-bytes over groupsize, if we can get xxd-compatibility this easy.

sharkdp commented 1 year ago

Fixed in 1df35eeb6312ff642922ca2185b53fd2f06d3ef7.

Another xxd feature that I find is most lacking is -r (reverse hexdump). Using it you can convert a hexdump into a binary, like this:

xxd file > file.hex
cat file.hex | xxd -r > reconstructed-file

That is indeed pretty cool. This would be a major new feature and I don't currently plan on adding it to hexyl. I think it's fair to close this for now.