I recently came across this # -*- sh -*-
at the top of a file with aliases in them. It was part of someone's dotfiles inside their bash directory and, until now, I've never seen it before. So, what is this and how is it different than using a shebang? I tried googling alternatives to a shebang, but came up with nothing that gives me a hint as to what the above is.
Bash Aliases and Dotfiles
536 views Asked by kyle At
1
Files with alias definitions do not need shebang lines, because executing them stand-alone would not add the definitions to the current shell, which is the point of alias definitions.
Instead, files with alias definitions must be sourced (run in the context of the current shell, with
source
or.
).Thus, what you're seeing is just an ordinary comment that indicates what specific shell (
sh
) the file is designed to be sourced from.