Reputation: 17601
I am trying to understand the difference between the following
Approach 1:
my_command myargs
Approach 2:
my_command myargs | /bin/bash/
My command passes in approach 1 but does not in approach 2. I was thinking both approaches were equivalent. Of course in approach 1 I have not done any commands/changed the path variables before doing my_command. In approach 2 I am just creating a brand new shell and piping my command into it.
Can someone explain the difference? Is it missing $PATH, environment variables etc? If so how can I echo/find out?
Upvotes: 1
Views: 6919
Reputation: 887469
Your "approach 2" pipes the output of my_command
to bash.
It's equivalent to
$(my_command myargs)
If you instead pipe the literal text, it will work:
echo my_command myargs | /bin/bash/
Upvotes: 3