Qual shell você está usando e porque? >:-)

Na verdade, depende da distro que usa. Então para matar sua curiosidade sobre os shells disponíveis, segue um resumo (em inglês pra você desenferrujar um pouco)

One many OSes, especially Linux based ones, sh is a link to bash.

In such case, there are still some differences in behavior where bash try to be more like traditional bourne shell when called sh, but it still accepts most bashisms.

On some other OSes, like Debian based ones, sh is provided by dash, not bash. That makes a much bigger difference as dash doesn't support bashisms, being designed to be a clean POSIX shell implementation.

On proprietary OSes, sh is often either provided by a POSIX compliant ksh88 which like dash, doesn't implement bashisms. On Solaris 10 and older, depending on what your PATH is, sh will likely be a legacy Bourne shell, predating POSIX.

In any case, you likely got the same output with your test simply because your script was not using any bash specific command, option or syntax.

When you run ./executable, what shell will be run essentially depends on the shebang written at the beginning of the .executable script. That will be bash if the shebang specifies it:

#!/bin/bash
....

If there is no shebang and you call the script from a POSIX compliant shell, the script should technically be executed by the first sh found in the PATH. Many shell interpreters like bash, dash and ksh are considering themselves to be POSIX so will interpret the script. Note that the SHELL environment variable is not used here.

fonte: https://unix.stackexchange.com/questions/270966/what-is-the-difference-between-using-bash-and-sh-to-run-a-script
answered Mar 20 '16 at 1:44 by jlliagre (collaborator)

Comentários

Entre ou Registre-se para fazer um comentário.