You are missing the mandatory : after the d in your while getopts line if the -d is to accept a parameter. Therefore your copy_dest is empty, and hence cp complains about the "missing operand". If you add "debug" lines such as
echo "Source parameter: $copy_source"
echo "Destination parameter: $copy_dest"
after your loop, you will see the problem. To solve, simply add the ::
while getopts s:d: flag
do
...
done
AlsoAlso, please note that in particular when dealing with filenames, you should always quote shell variables, as in
cp "$copy_source" "$copy_dest"
In additionIn addition, be aware that running a script as
sh test_cp.sh
will override the shebang-line #!/bin/bash and you cannot be sure that it is run under bash! If you want to ensure the correct shell is being used, you could either explicitly state
bash test_cp.sh arguments
or make the script file executable and run it as
./test_cp.sh arguments