In a bash file s.sh
, I have an Executor function to which I pass the commands to be executed. Whenever some command does not work as expected, this function outputs the command.
Executor()
{
if ! $*
then
echo "$*"
exit 2
fi
}
Now I am invoking this function -
Executor clangPath="Hello" make
(This is used to set the value of clangPath variable as "Hello" in the makefile)
This caused an error -
./s.sh: line 5: clangPath=Hello: command not found
[./s.sh] Error: clangPath=Hello make
However executing the same command like this works fine
if ! clangPath="Hello" make
then
echo "HelloWorld!"
fi
After looking at the error, I thought there might be a mistake with the string quotations, so I tried
exitIfFail clangPath='"Hello"' make
Even this resulted in an error -
./s.sh: line 5: clangPath="Hello": command not found
[./s.sh] Error: clangPath="Hello" make
What could be the reason for the error?