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.
>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