Shells: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
==Setup scripts== | ==Setup scripts== | ||
*'''.bash_profile''' is executed once when you login. | *'''.bash_profile''' is executed once when you login. | ||
**When you first get a mu2e account, you will be given an example which | ** When you first get a mu2e account, you will be given an [[example|ExampleBashProfile]] which should only contain the following modifications | ||
**It should source a "products/.../setup.sh" command which defines the PRODUCTS environmental, which allows you to access UPS products. | ** It should source a "products/.../setup.sh" command which defines the PRODUCTS environmental, which allows you to access UPS products. | ||
** source .bashrc | ** source ~/.bashrc | ||
*'''.bashrc''' | *'''.bashrc''' is executed for interactive non-login shells | ||
**When you first get a mu2e account, you will be given an example which would usually be modified | **When you first get a mu2e account, you will be given an [[example|ExampleBashrc]] which would usually be modified | ||
** set the prompt | ** set the prompt | ||
** set any aliases | ** set any aliases | ||
* we do not use ".login" or ".profile" which are variants for .bash_profile | * we do not use ".login" or ".profile" which are variants for .bash_profile | ||
* we do not recommend setting up UPS packages in the bash login scripts since this can get confusing | * we do not recommend setting up UPS packages in the bash login scripts since this can get confusing | ||
* the lab systems will also usually execute /etc/profile.d/*.sh and /etc/bashrc | |||
==Standards== | ==Standards== |
Revision as of 22:33, 21 September 2017
We use the bash linux shell exclusively for the interactive command line and shell scripting. In general, this is the most powerful shell and the professional's choice.
Setup scripts
- .bash_profile is executed once when you login.
- When you first get a mu2e account, you will be given an ExampleBashProfile which should only contain the following modifications
- It should source a "products/.../setup.sh" command which defines the PRODUCTS environmental, which allows you to access UPS products.
- source ~/.bashrc
- .bashrc is executed for interactive non-login shells
- When you first get a mu2e account, you will be given an ExampleBashrc which would usually be modified
- set the prompt
- set any aliases
- we do not use ".login" or ".profile" which are variants for .bash_profile
- we do not recommend setting up UPS packages in the bash login scripts since this can get confusing
- the lab systems will also usually execute /etc/profile.d/*.sh and /etc/bashrc
Standards
- scripts that intended to be executed by the average user at the command line, should be added to the user's path and can be named with no extension, so it looks built-in.
- scripts that are used in complex packages, or for special purposes, such as in monitoring, should have extension ".sh"
- scripts intended to be sourced should have the extension ".sh".
References
The Linux Documentation Project publishes a number of guides that are available online. We suggest:
- Bash Guide for Beginners, a comprehensive introduction.
- BASH Programming - Introduction HOW-TO, a shorter but less complete introduction.
- Advanced Bash Scripting Guide, starts at the beginning put goes more quickly to advanced ideas.