I have this problem, I have two (bourne) shell scripts, ony with subroutines, the other with the main program.
The problem lies in the argument-passing.
In my subroutine script I have this:
test()
{
echo "$1"
}
When called from the main program like this:
test "foo bar"
The result of the echo is ‘foo bar’ (note the single quotes)
When I modify my test to this:
test()
{
FOOBAR="foo bar";
echo "$FOOBAR"
}
Then the result does not contain quotes.
Then subroutinescript is sourced like this:
. testroutines.sh
Using sh -x I see the variable that is passed seems to be quoted with single quotes?
What am I missing?
It seems to have to do with the IFS, it was incorrectly set. It didn’t contain a space.