use #!/usr/bin/env bash instead of #!/bin/sh
use set -euo pipefail to enable strict error handling printf instead of echo because printf is more reliable
Use 2>&1 instead of >/dev/null to redirect both stdout and stderr to the same location
Use || exit 1 instead of >/dev/null 2>&1 to handle command failures. This will cause the script to exit with a non-zero exit code if the command fails. Instead of just ignoring the error.
Misc. optimizations
Changes
use
#!/usr/bin/env bash
instead of#!/bin/sh
use
set -euo pipefail
to enable strict error handlingprintf
instead ofecho
becauseprintf
is more reliableUse
2>&1
instead of>/dev/null
to redirect both stdout and stderr to the same locationUse
|| exit 1
instead of>/dev/null 2>&1
to handle command failures. This will cause the script to exit with a non-zero exit code if the command fails. Instead of just ignoring the error.Misc. optimizations