-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Correctly read in input from a non-interactive stream for the CLI #7440
Conversation
9c94c7c
to
1924945
Compare
c.Client.Addr()) | ||
} | ||
|
||
cmd, err := ioutil.ReadAll(os.Stdin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to read all of stdin for this? Prior to this change, stdin would have been read one line at a time, AFAICT. Should this use a bufio.Scanner instead, to handle the input line-by-line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to send the entire thing as part of the query with the current client library so I don't know if we really have a choice. Using a scanner and reading line by line won't really work since we want to send all of it as the same query and we can also split commands between multiple lines. Semi-colons are what we use as delimiters.
I do think we can possibly improve it in the future. I added support for sending the query as a file, but we don't currently use that in any of the clients.
1924945
to
9c15414
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
9c15414
to
b1dad45
Compare
If you pipe in a file to the `influx` CLI, it will not try to open the interactive line reader, but instead just send the contents of the entire file to the server.
b1dad45
to
2f5f995
Compare
I believe I am running into an issue caused by this pull request related to the TTY check introduced in one of the commits. When executing With the version of the CLI built from master i get the following behavior:
While simulating no tty allocation using ssh the command hangs indefinitely:
The same query succeeds using one of these two:
Notice that the query was successful using CLI 1.0.2:
We run into this issue when some queries executed using the latest influx CLI from a Cloud Foundry start up script for which a tty is not allocated started to fail. In that case the error was
This makes me believe that the influx CLI is still trying to read from STDIN in the second case. |
If you pipe in a file to the
influx
CLI, it will not try to open theinteractive line reader, but instead just send the contents of the
entire file to the server.
Fixes #6896.