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

curl tool won't search for curlrc (no leading dot) in XDG_CONFIG_HOME #12129

Open
jay opened this issue Oct 15, 2023 · 4 comments · May be fixed by #12135
Open

curl tool won't search for curlrc (no leading dot) in XDG_CONFIG_HOME #12129

jay opened this issue Oct 15, 2023 · 4 comments · May be fixed by #12135
Assignees

Comments

@jay
Copy link
Member

jay commented Oct 15, 2023

I did this

@b-jazz reported in #8208 (comment) that when curl is searching for the .curlrc file, it searches XDG_CONFIG_HOME for .curlrc but does not search it for curlrc (no leading dot).

The original reporter of #8208 reported that as well. When that issue was fixed by 764e4f0 it did not fix that part of the issue. Instead it was written in a specific way to not do that. findfile will search for curlrc (no leading dot) in $CURL_HOME/.config/curlrc and $HOME/.config/curlrc, but only if XDG_CONFIG_HOME is not set and .curlrc has not been found anywhere else.

Here's two typical setups and how curl currently behaves:

If CURL_HOME is not set, and XDG_CONFIG_HOME is set, and HOME is set, then the order is:

  • $XDG_CONFIG_HOME/.curlrc
  • $HOME/.curlrc
  • pw_dir/.curlrc

If CURL_HOME is not set, and XDG_CONFIG_HOME is not set, and HOME is set, then the order is:

  • $HOME/.curlrc
  • $HOME/.config/curlrc (this path is checked because XDG_CONFIG_HOME is not set)
  • pw_dir/.curlrc

Note pw_dir is usually the same as $HOME.

Note for brevity I've excluded how we also search for _curlrc when .curlrc is not found, since that logic just complicates understanding this and AFAICT it's not relevant here.

I expected the following

I'm not sure if this is a bug or not since the commit was written specifically not to strip the dot from curlrc when checking XDG_CONFIG_HOME, and I can't figure from the discussion why it was done that way.

curl/libcurl version

curl 8.4.0

operating system

Linux

@jay
Copy link
Member Author

jay commented Oct 15, 2023

-K, --config doc says it should be doing $XDG_CONFIG_HOME/curlrc so then is there not supposed to be any $XDG_CONFIG_HOME/.curlrc? If that's the case fixing it won't be as simple as turning on withoutdot member for XDG_CONFIG_HOME because there's logic that skips XDG_CONFIG_HOME in that case.

@b-jazz
Copy link

b-jazz commented Oct 15, 2023

Other applications that put stuff in ~/.config usually have no leading dot in that top level since the work of hiding all these configs is done at the top level itself. But whatever the outcome is, the real bug might be that the man page doesn’t match the implementation in the current version and that will cause confusion.

@jay
Copy link
Member Author

jay commented Oct 15, 2023

Well on further thought I think the ship has sailed so to speak, as it's likely that users are already using .curlrc in XDG_CONFIG_HOME since that's all that has worked, however we can add another ship for curlrc in XDG_CONFIG_HOME. It's too late now to recall it. Again I don't know why this wasn't done if it was a bug or what but I'm going to treat it as one and write up a PR

@bagder
Copy link
Member

bagder commented Oct 16, 2023

I think it is a bug.

jay added a commit to jay/curl that referenced this issue Oct 16, 2023
WIP

The order is now:

- $XDG_CONFIG_HOME/curlrc
- $XDG_CONFIG_HOME/.curlrc
- $XDG_CONFIG_HOME/_curlrc (if dotscore is true)

Fixes curl#12129
Closes #xxxx

Prior to this change there was no check for the dotless version of the
filename.
jay added a commit to jay/curl that referenced this issue Oct 29, 2023
The order is now:

- $XDG_CONFIG_HOME/curlrc
- $XDG_CONFIG_HOME/.curlrc
- $XDG_CONFIG_HOME/_curlrc (if dotscore is true)

Prior to this change there was no check for the dotless version of the
filename.

Fixes curl#12129
Closes #xxxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants