sleep-until: fix dry output

This commit is contained in:
PowerUser64 2023-04-07 04:46:12 -07:00
parent c03af6f32e
commit 28cde12854

View file

@ -8,8 +8,8 @@ if [ -n "$1" ] && date --date="$*" > /dev/null 2>&1; then
# Calculate the time in seconds to sleep by subtracting the future time from the current time
SLEEP_TIME="$(( $(date -f - +%s- <<< "$*"$'\nnow') 0 ))"
if [ "$SLEEP_TIME" -gt 0 ]; then
echo "Sleeping until: $(date --date="$*") (${SLEEP_TIME}s)"
if ! "$DRY"; then
echo "Sleeping until: $(date --date="$*") (${SLEEP_TIME}s)"
sleep "$SLEEP_TIME"
else
echo "$SLEEP_TIME"