I find it very suspicious that the error message has a leading quotation mark before https:
curl: (6) Could not resolve host: " https
Usually when the url is invalid you get something like that:
$ export TEST_URI="http::://dafsf//asdf"
$ curl -X -GET $TEST_URI
curl: (3) URL using bad/illegal format or missing URL
and when it's valid but could not be resolved you see this error:
$ export TEST_URI="https://analytics123.google.com:8080"
$ curl -X -GET $TEST_URI
curl: (6) Could not resolve host: analytics123.google.com
see ^ it prints just the host name, without the port number and the protocol.
I ran a few experiments on my mac and that's what I've got:
$ curl --version
curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
Release-Date: 2019-03-27
$ export TEST_URI="https:"
$ curl -X -GET $TEST_URI
curl: (6) Could not resolve host: https
which looks similar, but not quite the same, see the missing ".
Which is also possible to achieve:
$ export TEST_URI='"https'
$ curl -X -GET $TEST_URI
curl: (6) Could not resolve host: "https
aha, that looks about right. Let's modify it a little bit futher:
$ export TEST_URI='"https://analytics.google.com'
$ curl -X -GET $TEST_URI
curl: (6) Could not resolve host: "https
And the final test would look like:
$ export TEST_URI='"https://analytics.google.com"'
$ curl -X -GET $TEST_URI
curl: (6) Could not resolve host: "https
$ echo $TEST_URI
"https://analytics.google.com"
$ curl -X -GET '"https://analytics.google.com"'
curl: (6) Could not resolve host: "https
I hope that helps :)
PS. To complete the picture let's run this experiment:
$ echo 'abc'
abc
which is an expected, but not so intuitive behaviour:
$ echo 'abc'
abc
$ echo "'abc'"
'abc'
$ echo '"abc"'
"abc"
$ echo ""abc""
abc
$ echo ''abc''
abc
As you can see your shell is interpreting the quotes, both ' and ", before they get to echo
.
https://www.gnu.org/software/bash/manual/html_node/Quoting.html https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html#Single-Quotes
Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.
btw, why does this ''abc''
turns into abc
, but not into 'abc'
? :)