Skip to content

bugfix: better handle EOF#31

Merged
bitgamma merged 1 commit intokeycard-tech:developfrom
willianpaixao:bugfix-end-of-file
Oct 7, 2025
Merged

bugfix: better handle EOF#31
bitgamma merged 1 commit intokeycard-tech:developfrom
willianpaixao:bugfix-end-of-file

Conversation

@willianpaixao
Copy link
Contributor

While trying to fix #29, some files were hanging after the last command and took me while to figure out why.
Following the rabbit hole I found out it had to do with 9a8018e.
The changes are tested.

Copilot AI review requested due to automatic review settings September 10, 2025 13:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in EOF handling that was causing files to hang after the last command. The issue was traced back to commit 9a8018e and relates to how the shell processes end-of-file conditions during input reading.

Key Changes

  • Improved EOF handling logic in the shell's main read loop
  • Separated read error handling from command evaluation error handling
  • Added explicit check to break the loop when EOF is encountered

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +180 to +187
err := s.evalLine(line)
if err != nil {
return err
}

if readErr == io.EOF {
break
}
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

When readErr is io.EOF, the code still calls s.evalLine(line) before checking for EOF. If the last line doesn't end with a newline, line will contain the partial content and should be processed. However, if ReadString returns an empty line with EOF, this could lead to evaluating an empty command. Consider checking if line is non-empty or if it contains meaningful content before evaluation when EOF is encountered.

Suggested change
err := s.evalLine(line)
if err != nil {
return err
}
if readErr == io.EOF {
break
}
// Only evaluate non-empty lines at EOF
if readErr == io.EOF {
if strings.TrimSpace(line) != "" {
err := s.evalLine(line)
if err != nil {
return err
}
}
break
}
err := s.evalLine(line)
if err != nil {
return err
}

Copilot uses AI. Check for mistakes.
@bitgamma bitgamma merged commit fee6362 into keycard-tech:develop Oct 7, 2025
@bitgamma
Copy link
Collaborator

bitgamma commented Oct 7, 2025

thank you for your contribution!

@willianpaixao willianpaixao deleted the bugfix-end-of-file branch October 12, 2025 18:01
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.

bug: failed card identification

2 participants