Skip to content

Conversation

Regentag
Copy link

new option `-s'

hexyl_new

related issue : #16

@sharkdp
Copy link
Owner

sharkdp commented Jan 17, 2019

Thank you very much for your contribution!

I will take a closer look soon.
/cc @ErichDonGubler

Copy link
Contributor

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yaaay, thank you for doing this! Most of this LGTM, though I'm not terribly familiar with this codebase yet.

let mut f = File::open(filename)?;

// apply start offset
if start_offset > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that this is limited to files? I understand that Stdin doesn't implement Seek, but surely it'd be fairly easy to just ignore input from StdinLock by using BufRead's fill_buf and consume,

One defense I can see for this is that it's not immediately obvious (to me) how to make that robust. See discussion below about errors for my thoughts on this.


// apply start offset
if start_offset > 0 {
f.seek(SeekFrom::Start(start_offset))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, question: is this really an error if, say, the file simply wasn't as big as the specified offset? I think that this is a good default behavior, but I'm not sure about the case where the file size simply doesn't match.

This applies to the stdin discussion above since it's entirely possible to detect if there are any remaining bytes in stdin.

@sharkdp
Copy link
Owner

sharkdp commented Jan 26, 2019

Happy to review this once the questions by @ErichDonGubler are answered.

@ErichDonGubler
Copy link
Contributor

Just pinging @Regentag to take a look at the comments made so far -- excited to get your stuff through, just wanted to have some discussion! :)

@keplersj
Copy link

Any update on this? I'd love to use this feature @Regentag

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

Successfully merging this pull request may close these issues.

4 participants