NERSC / shifter

Shifter - Linux Containers for HPC
Other
348 stars 65 forks source link

activate_gpu_support.sh: use proper Bash syntax #278

Closed maxim-belkin closed 4 years ago

maxim-belkin commented 4 years ago

Fix contrib/gpu/activate_gpu_support.sh script to use proper Bash syntax:

  1. Use double [[ ... ]] instead of [ ... ] [[ ... ]] is more robust than [ ... ] and lets use use variables without having to put double quotes around them. Currently, log function is called by parse_command_line_arguments when wrong number of input arguments is specified. The log functions fails because of the if [ $is_verbose_active = false ]; then line because is_verbose_active is not set and variables have to be double-quoted in [ ... ].

  2. double-quote all variables where necessary E.g.: mount_dir=$(dirname "$mount_point")

  3. Use proper Bash comparison Replace if [ ! $# -eq 4 ]; then with if [[ $# -ne 4 ]]; then

  4. Avoid masking return values Example: change

    local mount_dir=$(dirname $mount_point)

    to

    local mount_dir
    mount_dir=$(dirname "$mount_point")

    because combined declaration + assignment masks the return value of dirname $mount_point and lets the script to proceed even when dirname fails.

scanon commented 4 years ago

Let me see if we can test this locally. I think we are using a different approach. I will share that with you via Slack once I confirm.

scanon commented 4 years ago

I think we should deprecate this and replace it with examples using modules.

maxim-belkin commented 4 years ago

I think we should deprecate this and replace it with examples using modules.

It makes to deprecate the script for Shifter 18, so I'm going to close this. If you want, I can submit it against shifter-16.08 branch -- just let me know.