Based on what I've read online, sh
is essentially an alias for bash
; running a shellscript with sh
will behave the same as if it's run with bash
.
In my experience this is not entirely true, as newlines are processed differently. What exactly is the difference between sh
and bash
, and as zsh
is now the default shell does anyone know if sh
will change in future versions of Mac OS?
Consider the following code:
sh -c "echo \"Hello\nWorld\""
This should produce the following output:
Hello
World
However when run with bash
:
bash -c "echo \"Hello\nWorld\""
The newline is not output:
Hello\nWorld
Thanks in advance!
/bin/sh
is just a wrapper which executes the shell/var/select/sh
points to (which in my case isbash
), seeman sh
for details.strings /bin/sh
to check.