Given the following string variable
VAR="foo bar"
I need it to be passed to a bash function, and accesses it, as usual, via $1
. So far I haven't been able to figure out how to do it:
#!/bin/bash
function testfn(){
echo "in function: $1"
}
VAR="foo bar"
echo "desired output is:"
echo "$(testfn 'foo bar')"
echo "Now, what about a version with \$VAR?"
echo "Note, by the way, that the following doesn't do the right thing:"
echo $(testfn "foo bar") #prints: "in function: foo bar"