Some suggestions:
#!/usr/bin/env bash
is a more portable shebang line.function prepare_volumes_for_exit()
can be simplified toprepare_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 thesudo
s and tell the user to run the whole script as root. -
can be improved aswhile read -r drive_number volume_location vc_mapper mount_location … done <<< $(veracrypt -t -l)
This way, no word splitting happens on the input, and commands within thewhile read -r -u9 drive_number volume_location vc_mapper mount_location … done 9< <(veracrypt -t -l)
while
loop which happen to read from stdin won't break the loop.