I'm in the process (v.painful) of learning the bash language and I'm fighting with the code below. Any explanation for it's current behaviour would be greatly appreciated.
code
#!/usr/bin/env bash
function useless
{
echo "$1"
return 0
}
function call-and-report
{
TEST_CRITERIA="$1"
if $TEST_CRITERIA
then
echo "passed"
else
echo "failed"
fi
}
call-and-report $(useless "Hello World")
issue
I'm expecting the following console output:
Hello World
passed
Instead I'm seeing the following output:
./../test.sh: line 13: Hello: command not found
failed
$1incall-and-reportis a string (the output fromuseless) and not anything indicating ifuselesshas been successful or not.