DEV Community

Jonas Brømsø
Jonas Brømsø

Posted on

2 1

TIL: Handling shell sensitive characters in URL when using curl/httpie

Handling shell sensitive characters in URL when using curl/httpie

Sometimes you want to request an URL from the command-line, but the URL contains characters bearing meaning in your shell.

$ curl --header Accept:application/json https://USERID:funkyPassMo|)@eksempel.dk/dostuff
-bash: syntax error near unexpected token '|'
Enter fullscreen mode Exit fullscreen mode

Simply quote the URL when using curl

$ curl --header Accept:application/json \ 
"https://USERID:funkyPassMo|)@eksempel.dk/dostuff"
Enter fullscreen mode Exit fullscreen mode

And if your special character is a quote ", quote differently, use ' for example

$ curl --header Accept:application/json \
'https://USERID:funky"PassMo|)@eksempel.dk/dostuff'
Enter fullscreen mode Exit fullscreen mode

See also: http://wiki.bash-hackers.org/syntax/quoting

Originally posted in my TIL collection

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more