I have the following loop to read and set variables passed to a bash script
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="$2"
# echo $1 $2 // Optional to see the parameter:value result
fi
shift
done
For example one can call it via:
sh test.sh --name myname --family myfamily
How can I change it to call it as:
sh test.sh --name=myname --family=myfamily
getoptsorgetoptgetoptssupport=between option-value? However, I found above code or the modifcation in accepted answer an easy solution.