From the bash
man page:
Aliases are not expanded when the shell is not interactive, unless the expand_aliases
shell option is set using shopt
(see the
description of shopt
under SHELL BUILTIN COMMANDS below).
In other words, aliases are not enabled in bash shell scripts by default. When you run the script with bash
, it fails.
Your sh
appears to default to allowing aliases in scripts. When you run the script with sh
, it succeeds.
./command.sh
happens to work because your shebang is malformed (you're missing the !
in #!/bin/bash
).