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

Error prompt not detected if prompt is set to empty string #24

Open
biggianteye opened this issue Sep 13, 2019 · 1 comment
Open

Error prompt not detected if prompt is set to empty string #24

biggianteye opened this issue Sep 13, 2019 · 1 comment

Comments

@biggianteye
Copy link
Contributor

biggianteye commented Sep 13, 2019

If $prompt is set to an empty string ("") and $promptError is set as non-empty (eg. "ERROR") then any error condition is never detected.

Using the example from the README, this is what would happen:

Graze\TelnetClient\TelnetResponse {#188
  #isError: false
  #responseText: "I'm sorry, Dave. I'm afraid I can't do that\nERROR"
  #promptMatches: array:1 [
    0 => ""
  ]
}

The reason that this happens is that prompt checking (getResponse() in Graze\TelnetClient\TelnetClient) happens before error checking. In the case of an empty prompt it always matches and so the error prompt check never happens.

Some thoughts on fixes:

  • Change the ordering such that error prompt checking happens first.
  • Don't attempt any matching if a prompt is an empty string
@biggianteye
Copy link
Contributor Author

(Note that I didn't actually test out what the exact response of that command would be. It's an educated guess based on my reading of the code.)

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

1 participant