swab(1)
- swap bytes #22
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This pertains to #23 in that it fulfills functionality offered in POSIX by dd(1p), specifically
dd conv=swab
.swab(1) swaps bytes in standard input to standard output. The default word size is 2, as in two-byte words with the latter half of the word (in this case, one byte) being output before the former half of the word.
If there are remaining bytes less than the word size they're left unconverted. Word sizes up to 16 (128 bits) will be supported.
The usefulness of such a tool is limited but this should be small and easy to make, and would fill in more POSIX functionality in a way that is simpler than POSIX.
swab(1) - swap bytesto `swab(1)` - swap bytesMy current conundrum is that there are multiple useful types of byte reversal:
The third should be relegated to a separate utility as it's higher level (plaintext) than endianness/bit order tomfoolery. Should the former two be separate utilities?
Ah, I didn’t realize GNU had a utility called
rev
already. Will come up with another name.On first consideration, I think it makes sense for all three to be separate utilities.
swab(1) won't reverse bytes in a given word size but instead print the latter half of the word before the former half; actual reversal isn't relevant to the job, which is endianness in binary files.
I've started to implement this (with a lot of help from Emma and Mars as I am not used to Rust) and have a working but severely unpolished start.