Closed eth-p closed 3 years ago
FYI @tommilligan: only if you are interested.. since you implemented --display-offset
. Also FYI @ErichDonGubler since you implemented --skip
.
Disclaimer: I'm interested in resolving this. Right now, I'm just going to triage things, but I hope to have a solution after I finish researching and put in my vote for my elections as a US resident.
To me, the implemented behavior is desirable, and it's the documentation that should be re-aligned with current behavior -- this looks like docs I missed updating in my PR for --skip
. I can go into more detail (and should, since it would be good for a commit message fixing it), but being on mobile doesn't lend well to my long-windedness ATM. :)
I think you could argue this both ways if we were implementing the first hex viewer - however, the behaviour pointed out by @eth-p is the behaviour implemented by xxd
and I think it's desirable the two should align.
Example: xxd
and hexyl
run with the same flags, showing different address output:
$ cat LICENSE-MIT | head -n1 | hexyl -s 0x10 -o 0x20
┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│00000020│ 72 65 62 79 20 67 72 61 ┊ 6e 74 65 64 2c 20 66 72 │reby gra┊nted, fr│
│00000030│ 65 65 20 6f 66 20 63 68 ┊ 61 72 67 65 2c 20 74 6f │ee of ch┊arge, to│
│00000040│ 20 61 6e 79 20 70 65 72 ┊ 73 6f 6e 20 6f 62 74 61 │ any per┊son obta│
│00000050│ 69 6e 69 6e 67 20 61 20 ┊ 63 6f 70 79 0a │ining a ┊copy_ │
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘
$ cat LICENSE-MIT | head -n1 | xxd -s 0x10 -o 0x20
00000030: 7265 6279 2067 7261 6e74 6564 2c20 6672 reby granted, fr
00000040: 6565 206f 6620 6368 6172 6765 2c20 746f ee of charge, to
00000050: 2061 6e79 2070 6572 736f 6e20 6f62 7461 any person obta
00000060: 696e 696e 6720 6120 636f 7079 0a ining a copy.
Opened #119
I think you could argue this both ways if we were implementing the first hex viewer - however, the behaviour pointed out by @eth-p is the behaviour implemented by
xxd
and I think it's desirable the two should align.
I agree :+1:
According to the help text,
--display-offset
should add to the file position sidebar's offset:In practice, this is actually not the case. Rather than adding the offset, it sets the offset. That means that when using
--display-offset
in conjunction with--skip
, the usual interactions between--skip
and the position are negated entirely. For example:With those arguments, it should have started at
1FF
instead of100
.Note: I'm doing a class assignment regarding creating tests (from scratch) for an open-source command line program, and I chose hexyl for it. You might have a couple more of these on the way, depending on what the assignment brings to light :)