I have a simple bash script called foo.sh like this:
#!/bin/bash echo "Foo!"
When I run it as
./foo.sh I get the
Foo! message and everything's fine.
But if I
echo "Foo!" directly from the console, then I obtain the expected behavior and message:
bash: !": event not found.
I understand that the
! is presented as a previous command and if used inside p.e. single quotes, then it's considered as a literal.
I'm just wondering what is the difference here that running a script with that
echo "Foo!" (even with
source ./foo.sh works but directly from the console it doesn't.