On writing few commands at command line, it works, However placing the same in a script file throws error. Here is what I am trying to do:
USER=chandan-jay
REPO=test-1
echo "GitHub UserID: $USER"
echo "Repository Name: $REPO"
str={\"name\":\"$REPO\"}
curl_response=($( curl -u "$USER" -H "Content-Type:application/json" https://api.github.com/user/repos -d $str ))
echo ${curl_response[@]}
when executing above code line after line on shell if works file.
When putting them together in a .sh file it throws syntax error (line number 13 is curl_response):
__git_create_repo_CLI.sh: 13: git_create_repo_CLI.sh: Syntax error: "(" unexpected__
#!/bin/bashat the top of your script? If not, it might be defaulting to/bin/sh, which might not support arrays like that.#!/bin/shand I got error but with#!/bin/bashit works fine.