Skip to main content
1 of 2
l0b0
  • 9k
  • 21
  • 36

Some suggestions:

  • #!/usr/bin/env bash is a more portable shebang line.
  • function prepare_volumes_for_exit() can be simplified to prepare_volumes_for_exit().
  • Using sudo within a script is generally discouraged, since it makes it easy to do really bad things without explicit user consent. Instead, remove the sudos and tell the user to run the whole script as root.
  • while read -r drive_number volume_location vc_mapper mount_location
    …
    done <<< $(veracrypt -t -l)
    
    can be improved as
    while read -r -u9 drive_number volume_location vc_mapper mount_location
    …
    done 9< <(veracrypt -t -l)
    
    This way, no word splitting happens on the input, and commands within the while loop which happen to read from stdin won't break the loop.
l0b0
  • 9k
  • 21
  • 36