Skip to content

Curl should expand ~ and env vars in ~/.curlrc #2317

Description

@nagromc

I've read https://curl.haxx.se/docs/knownbugs.html, https://curl.haxx.se/docs/todo.html, and https://curl.haxx.se/docs/manpage.html. Maybe I'm missing something. If so, please excuse me.

I did this

$ echo "--config ~/.curlrc_local" > ~/.curlrc
$ cat ~/.curlrc
--config ~/.curlrc_local
$ echo "--head" > ~/.curlrc_local
$ cat ~/.curlrc_local
--head
$ curl https://example.org
Warning: error trying read config from the '~/.curlrc_local' file
<!doctype html>
<html>
<head>
    <title>Example Domain</title>
...

Curl does not expand ~ before running the command.

I've tried the following content in ~/.curlrc. None of them worked:

  • --config "~/.curlrc_local"
  • --config '~/.curlrc_local'
  • config = ~/.curlrc_local
  • config = "~/.curlrc_local"
  • config = '~/.curlrc_local'

Same if I try to replace ~ by $HOME.

I expected the following

I expected to have HTTP headers.

$ echo "--config ~/.curlrc_local" > ~/.curlrc
$ cat ~/.curlrc
--config ~/.curlrc_local
$ echo "--head" > ~/.curlrc_local
$ cat ~/.curlrc_local
--head
$ curl https://example.org
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Fri, 16 Feb 2018 18:03:08 GMT
Etag: "1541025663+gzip"
Expires: Fri, 23 Feb 2018 18:03:08 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (dca/2486)
X-Cache: HIT
Content-Length: 1270

When running the previous commands, I was expecting Curl to expand ~ into my home directory (here /home/morgan) to parse my custom configuration.

It does work well if:

  • I write directly in ~/.curlrc before, obviously:
    echo "--head" > ~/.curlrc
  • I "expand" manually:
    echo "--config /home/morgan/.curlrc_local" > ~/.curlrc
    echo "--head" > ~/.curlrc_local

curl/libcurl version

$ curl -V output
curl 7.55.1 (x86_64-pc-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/2.0.2 libpsl/0.18.0 (+libidn2/2.0.2) librtmp/2.3
Release-Date: 2017-08-14
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy PSL

operating system

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 17.10
Release:        17.10
Codename:       artful
$ uname -a
Linux xxx 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions