Skip to content

Instantly share code, notes, and snippets.

@petervandivier
Last active August 11, 2021 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petervandivier/e4a314d3f7a4b20dbba332142afdc0b1 to your computer and use it in GitHub Desktop.
Save petervandivier/e4a314d3f7a4b20dbba332142afdc0b1 to your computer and use it in GitHub Desktop.
gdate_best_date.sh
#!/usr/bin/env bash
#
# usage: dot-source to export to the current shell context
# . ./gdate_best_date.sh
#
# remove the override with `unset -f`:
# unset -f date
#
if ! ( date --version 2>&1 | grep GNU > /dev/null ); then
function date() {
gdate "$@"
}
if ! ( date --version 2>&1 | grep GNU > /dev/null ); then
echo "GNU Coreutils \`date\` (\`gdate\`) was not found and is required. Exiting." 1>&2
exit 1
fi
fi