简体   繁体   中英

Bash Aliases and Dotfiles

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. 家当

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM