Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xxd -i: not expected behaviour #286

Open
aheirman opened this issue Jun 23, 2021 · 8 comments
Open

xxd -i: not expected behaviour #286

aheirman opened this issue Jun 23, 2021 · 8 comments

Comments

@aheirman
Copy link

As far as I can tell the upstream for the default xxd is vim, with an example of the expected xxd -i behavior from there ( https://vim.fandom.com/wiki/Hex_dump#Generating_C_source_for_a_binary_file )

xxd -i in toybox just gives the bytes converted to hex with , in between without the required c.
In the example provided toybox xxd -i would give

  0x00, 0x01, 0x02, 0x03, 0x30, 0x31, 0x32, 0x33, 0x04, 0x05, 0x06, 0x07,
  0x44, 0x45, 0x46, 0x47, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f

and not the expected:

unsigned char sample_bin[] = {
  0x00, 0x01, 0x02, 0x03, 0x30, 0x31, 0x32, 0x33, 0x04, 0x05, 0x06, 0x07,
  0x44, 0x45, 0x46, 0x47, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
};
unsigned int sample_bin_len = 32;
@enh-google
Copy link
Collaborator

enh-google commented Jun 24, 2021 via email

@landley
Copy link
Owner

landley commented Jun 24, 2021 via email

@aheirman
Copy link
Author

Have -C produce the prefix/suffix

Do you mean xxd -C or xxd -C -i because xxd -C -i would be 'more' compliant.

Although I would prefer xxd -i to behave as expected, since I've used it in build scripts and I'm not alone(https://github.com/caramelli/yagears, don't want to look for more examples).

I don't know if many people/projects use xxd -i in the toybox way.

@enh-google
Copy link
Collaborator

enh-google commented Jun 24, 2021 via email

@landley
Copy link
Owner

landley commented Jun 24, 2021 via email

@enh-google
Copy link
Collaborator

enh-google commented Jun 24, 2021 via email

@landley
Copy link
Owner

landley commented Jun 24, 2021 via email

@landley
Copy link
Owner

landley commented Jun 24, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants