$ alias bb=hello $ cat test.sh #! /bin/bash alias bb echo "$bb" $ ./test.sh ./test.sh: line 3: alias: bb: not found
Is it because alias is not inherited by a child bash process for the script from the parent bash process?
$ source ./test.sh alias bb='hello'
The content in the script is executed in the bash process, so the alias exists. But the alias is not expanded.
Bash manual says
Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt
But the content in the script being sourced is executed in the interactive bash process, so why is the alias not expanded?