Bash script to format a block device (hard drive or Flash drive) in UDF. The output is a drive that can be used for reading/writing across multiple operating system families: Windows, macOS, and Linux. This script should be capable of running in macOS or in Linux.
See comments in code: "TODO not sure why the following is required on bash 3.2.51(1) on OS X (doesn't exit with false even with set -e)"
Example:
# verify that DEVICE doesn't have partition number on end, or that it's in OS X format
(echo "$DEVICE" | egrep -q '^([hs]d[a-z]|disk[0-9]+)$') || (echo "[-] <device> is of invalid form" >&2 && false)
# TODO not sure why the following is required on bash 3.2.51(1) on OS X (doesn't exit with `false` even with 'set -e')
RET=$?; if [[ $RET -ne 0 ]]; then
exit $RET
fi
There are several occurrences of this logic in the code (all marked with TODO).
See comments in code: "TODO not sure why the following is required on bash 3.2.51(1) on OS X (doesn't exit with
false
even withset -e
)"Example:
There are several occurrences of this logic in the code (all marked with
TODO
).