I have a script.sh that performs the "clone" operation of a git repository. Currently, the script works correctly with the target branch written in hard on the corresponding line.
/usr/bin/git clone https://my-url-repository --branch master --single-branch
If I replace "master" with "$1",
/usr/bin/git clone https://my-url-repository --branch $1 --single-branch
it can't complete the operation because it doesn't correctly take the branch and throws a fatal error.
warning: Could not find remote branch e to clone.
fatal: Remote branch e not found in upstream origin
However, if I print on screen the parameter $1 or ${1}, the entered value is displayed correctly.
#!/bin/bash
if [ -n "$1" ]; then
echo Building from branch "["$1"]"
else
echo "Please, enter branch name"
exit
fi
Can you help me?