Skip to content

Commit 363a847

Browse files
author
Jonathan Carter
authored
Merge pull request #94 from aimileus/macos
Support macOS with Homebrew gnu-getopt
2 parents 1294511 + 6f6d120 commit 363a847

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/zfs-auto-snapshot.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,13 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
224224
# main ()
225225
# {
226226

227-
GETOPT=$(getopt \
227+
if [ "$(uname)" == "Darwin" ]; then
228+
GETOPT_BIN="$(brew --prefix gnu-getopt 2> /dev/null || echo /usr/local)/bin/getopt"
229+
else
230+
GETOPT_BIN="getopt"
231+
fi
232+
233+
GETOPT=$($GETOPT_BIN \
228234
--longoptions=default-exclude,dry-run,fast,skip-scrub,recursive \
229235
--longoptions=event:,keep:,label:,prefix:,sep: \
230236
--longoptions=debug,help,quiet,syslog,verbose \
@@ -578,7 +584,7 @@ SNAPPROP="-o com.sun:auto-snapshot-desc='$opt_event'"
578584

579585
# ISO style date; fifteen characters: YYYY-MM-DD-HHMM
580586
# On Solaris %H%M expands to 12h34.
581-
DATE=$(date --utc +%F-%H%M)
587+
DATE=$(date -u +%F-%H%M)
582588

583589
# The snapshot name after the @ symbol.
584590
SNAPNAME="${opt_prefix:+$opt_prefix$opt_sep}${opt_label:+$opt_label}-$DATE"

0 commit comments

Comments
 (0)