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
[WIP] tool_parsecfg: Support .netrc and .curlrc on Windows #3989
[WIP] tool_parsecfg: Support .netrc and .curlrc on Windows #3989
Conversation
BTW. |
I don't think it's necessary. It has long been documented to use _curlrc and _netrc and I don't think there are any problems from that so why change it? But I'm curious about the git for windows bug, can you give a reference where it talks about _curlrc? |
Due to the mention of git for windows, maybe @dscho has a thought? |
a5d2f67
to
ba8950a
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.
I like the idea, and suggested a couple of changes that would IMO improve the PR.
And I agree with the concern that it does not make much sense to do this only for _curlrc
but not for _netrc
. The more important "known issue" of Git for Windows is about .netrc
being ignored, in favor of _netrc
.
@@ -34,7 +34,12 @@ | |||
|
|||
#include "memdebug.h" /* keep this as LAST include */ | |||
|
|||
#if defined(WIN32) | |||
#define CURLRC ".curlrc" | |||
#define CURLRC_LEGACY "_curlrc" |
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.
Makes sense to me!
} | ||
} | ||
} | ||
|
||
/* If we didn't find CURLRC in either location we loop round and try | ||
CURLRC_LEGACY next */ |
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.
I have to say that this indentation change makes the patch quite hard to review, at least for me.
Besides, I do not like that CURLRC_LEGACY
is defined but then used in anything but an #ifdef CURLRC_LEGACY
code block.
Therefore, I would like to suggest a different strategy, based on a simple and elegant goto
. In particular:
- add a label, say,
retry_reading_curlrc:
instead of thefor
statement, - Replace the comment
/* Don't bother checking if it exists - we do that later */
and the line following it by something like this:
file = fopen(filebuffer, FOPEN_READTEXT);
if(file != NULL) {
filename = filebuffer;
}
#ifdef CURLRC_LEGACY
else if (strcmp(CURLRC_LEGACY, filename)) {
filename = CURLRC_LEGACY;
goto retry_reading_curlrc;
}
#endif
That will be much easier to review, and therefore it will be much harder for bugs to creep in.
Thanks for the ping! I would love to be able to get rid of that "Known Issues" entry. And I agree that it makes a total lot of sense to look for |
@jay just because users acquiesce with the status quo does not mean that we should refrain from improving it...
It actually talks about |
No problem - that was next on my list but I must admit I forgot to mention it in the PR description :( |
I'll just voice my support for making sure that curlrc and netrc get the same treatmeant with regards to leading dot/underscore to reduce the amount of possible confusion. |
No problem - I was going to work on that as a separate patch set but I think with hindsight I will update the title of this PR and make it part of this patch set. |
ba8950a
to
629ba0b
Compare
629ba0b
to
7452678
Compare
…rocessor Given that filename points to CURLRC use this variable instead of the pre-processor variable as it allows us to change it easily when supporting both .curlrc and _curlrc on Windows.
Support and prefer .curlrc over _curlrc in Windows. Other OSes are unaffected by this change; so _curlrc on DOS and .curlrc on all others.
7452678
to
029b438
Compare
029b438
to
39eaaaf
Compare
This was replaced by #4230 |
Support and prefer .curlrc over _curlrc in Windows. Other OSes are unaffected by this change; so _curlrc on DOS and .curlrc on all others.
I know .curlrc on Windows has been discussed before and without checking the mailing lists I can't remember the last time it was. However this is my take on trying to support .curlrc on Windows as well as maintaining support for _curlrc (as Windows doesn't have the same limitation as DOS).
Note: I haven't worried about supporting older versions of Windows that don't support long file names - ie versions prior to Windows 95 that are not Windows NT based.
In summary it performs the check for the CURLRC file in both the 'home' folder and the current executable directory as per the current behaviour, but loops round this code twice. The first time looking for .curlrc and then if that fails looking for _curlrc the second time.
It fixes a long known "git for windows" bug bear (as it's been in their release notes since I have been involved with curl - and using git).
If the general consensus is that we should proceed with 'fixing' this then I would propose something similar for _netrc too.
I would appreciate feedback and comments.
Many thanks