-
Notifications
You must be signed in to change notification settings - Fork 329
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
Refactor env, source, and exec #78
Conversation
Neat work @eliangcs ! I've stumbled upon a bug with cmd output redirection lexer definition: https://api.github.com> get >> /tmp/test # the file path is highlighted as syntax err I believe this bug has been already present in my original PR. It's specific to the I've also noticed few other issues with command output redirection:
|
@fogine Thanks for finding the bug! I just pushed several patches:
As for
The change is actually intentional, so that it is consistent with HTTPie's redirected output. See this example: $ http http://httpbin.org/user-agent
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 35
Content-Type: application/json
Date: Fri, 16 Sep 2016 17:15:08 GMT
Server: nginx
{
"user-agent": "HTTPie/0.9.6"
}
$ http http://httpbin.org/user-agent > out.txt
$ cat out.txt
{
"user-agent": "HTTPie/0.9.6"
} |
@eliangcs , thanks for spending the time on this recently!
This actually still does not work for
I see. That makes sense... Just for possible readers, the "issue" is solved by explicitly defining @eliangcs , I'm interested in seeing how have you solved the problem with stripping Thanks! |
@fogine I don't think a newline char at the end of an The output redirection of an |
Hmm, good point @eliangcs , however I don't think this design decision is gonna be much useful to users of |
@fogine Normally, a server should return a newline char at the end if the response is in text format. What use case are you thinking about? |
@eliangcs , that applies only for Do you think there are other advantages in the current behavior except the consistency ? Ps.: > curl -X GET https://api.github.com >> /tmp/test |
@fogine Besides consistency, I can't think of a good way to tell if a response is text or binary without looking at the content. The best we can do is guess from the What's your opinion on this? |
@eliangcs , what if we approached this from opposite side? if we were to append to a file, we would have done something among these steps: Is the file we're appending to empty (or does not exist) ? if so, just write data we've got to the file, otherwise try to determine if the file we're appending to is either binary or text file. if we append to a "text file", append a new line character to the file before appending actual request data. Any thoughts? I might be missing something... |
@fogine how do you define a "text file"? By checking its content-type or content? |
@eliangcs , that was my thinking... I think this way it would be least error-prone... less exceptions to handle... |
@fogine That sounds ad-hoc, and I'm trying to avoid ad-hoc code. I guess we can do it when there are more feature requests like this and do it as a user configurable option. Thanks for the advice! |
No problem, thanks for your time @eliangcs while discussing this. I've not found any other bugs in implemented features... so it's good to go I guess. |
Refactor PR #73.
@fogine Would you like to review it?