So I am trying to pass variable arguments to a bash function. Here is what my code looks like
function log_output(){
args=("$@")
for statement in ${args}
do
echo "${statement}"
done
}
When I make the following call log_output "hello bye"
I expect the function to print hello bye in one line. However currently its printing it in two different lines. Why is the string "hello bye" being treated as two arguments by the function? What am I doing wrong?
Much appreciated!