software:shell

# Differences

This shows you the differences between two versions of the page.

 software:shell [2019/05/22 09:38]meesters [Best Practices] software:shell [2019/10/12 07:38]meesters removed 2019/10/12 07:38 meesters removed2019/08/25 21:11 meesters [Best Practices] 2019/08/25 21:10 meesters [Best Practices] 2019/08/23 21:16 meesters [Other Shells] 2019/08/20 20:27 meesters 2019/05/22 09:38 meesters [Best Practices] 2019/01/14 08:58 meesters 2019/01/14 08:55 meesters 2019/01/14 08:54 meesters 2019/01/14 08:39 meesters created 2019/10/12 07:38 meesters removed2019/08/25 21:11 meesters [Best Practices] 2019/08/25 21:10 meesters [Best Practices] 2019/08/23 21:16 meesters [Other Shells] 2019/08/20 20:27 meesters 2019/05/22 09:38 meesters [Best Practices] 2019/01/14 08:58 meesters 2019/01/14 08:55 meesters 2019/01/14 08:54 meesters 2019/01/14 08:39 meesters created Line 24: Line 24: | TENEX-C-Shell ​                 | ''​\$ tcsh'' ​  | ''#​!/​bin/​tcsh'' ​       | | TENEX-C-Shell ​                 | ''​\$ tcsh'' ​  | ''#​!/​bin/​tcsh'' ​       | | Z-Shell ​                       | ''​\$ zsh'' ​   | ''#​!/​bin/​zsh'' ​        | | Z-Shell ​                       | ''​\$ zsh'' ​   | ''#​!/​bin/​zsh'' ​        | + + + You may use any of these shells - be advised, however, that: + * We only support Bash. + * Some Cluster features (e.g. the environment exported by SLURM) might not be available. + ​ + + If you choose to use a different shell - in this example ''​zsh''​ -- you can try this snippet (in ''​bash''​):​ + + + if [[ \$- == *i* ]]; then + if [[ "​\$SLURM_CLUSTER_NAME"​ == ""​ ]]; then + if [ -z \${SBASH+x} ]; then + export SHELL=/​bin/​zsh + exec /bin/zsh -l + fi + fi + fi + ​ + + It activates the ''​zsh'',​ e.g. upon login, when placed in the ''​.bashrc''​-file. Calling + + export SBASH=1 && bash + ​ + will let you return to ''​bash''​ at any time. ===== Best Practices ===== ===== Best Practices ===== - + - This is a completely arbitrary list - and only on Bash! We make no claim for it to be complete. + This is a completely arbitrary list - and only applicable to Bash! We make no claim for it to be complete. ​ - - //Always comment your script//\\ \\ This is a recommended practice which is not only applied to shell scripting but all other kinds of programming. Writing comments in a script helps you or some else going through your script understand what the different parts of the script do.\\ \\ For starters, comments are defined using the ‘#’ sign. + - //Always comment your code//\\ \\ This is a recommended practice which is not only applied to shell scripting but all other kinds of programming. Writing comments in a script helps you or some else going through your script understand what the different parts of the script do.\\ \\ For starters, comments are defined using the ‘#’ sign. - //Make a script exit when it fails//\\ \\ Sometimes bash may continue to execute a script even when a certain command fails, thus affecting the rest of the script (may eventually result in logical errors). Use the line below to exit a script when a command fails: #​let script exit if a command fails - //Make a script exit when it fails//\\ \\ Sometimes bash may continue to execute a script even when a certain command fails, thus affecting the rest of the script (may eventually result in logical errors). Use the line below to exit a script when a command fails: #​let script exit if a command fails set -o errexit ​ set -o errexit ​