I mean, in ~/.profile
, a function doit
will say Welcome
when user login, but say other words when user execute doit
later.
doit() {
if some_test_here; then
echo "Running within ~/.profile. Welcome."
else
echo "Called by user."
fi
}
doit
I think ~/.profile
is better on Mac for ~/.bash_profile
on Linux. So I use ~/.profile
as example.
Two ways to are to pass an argument, or to check the environment.
Use an argument that is only used by the call in
.profile
.Check the environment for a variable set by .profile