Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

git clone inside bash script: fatal: protocol '"https' is not supported

I am writing a bash script that reads a Github token from a file, and then calls the Github api to get the repositories under my Github account, and then run git clone $url for all the urls in the response. The script looks like this:

#!/usr/bin/env bash

token=$(grep -oP "(?<=\")(.*)(?=\")" config.toml)
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $token" https://api.github.com/user/repos | jq '.[] | .html_url' | while read url; do git clone $url $1; done

However, I am getting the error fatal: protocol '"https' is not supported on the cloning step. When I run git clone manually in the shell however, it works. It only does not work when running the bash script itself.

What could possibly prevent git clone to fail in this manner in a bash script but not inside of the shell itself? I am also running this in Ubuntu under Windows WSL2.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

What could possibly prevent git clone to fail in this manner in a bash script but not inside of the shell itself?

There is no protocol "https, there is https. You have to remove the ".

Consider researching how to use jq and pass data to bash. Typical solution would be jq -r

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading