Skip to content

Commit 6f6d120

Browse files
committed
Support macOS with Homebrew gnu-getopt
1 parent 3d9992b commit 6f6d120

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
@@ -207,7 +207,13 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
207207
# main ()
208208
# {
209209

210-
GETOPT=$(getopt \
210+
if [ "$(uname)" == "Darwin" ]; then
211+
GETOPT_BIN="$(brew --prefix gnu-getopt 2> /dev/null || echo /usr/local)/bin/getopt"
212+
else
213+
GETOPT_BIN="getopt"
214+
fi
215+
216+
GETOPT=$($GETOPT_BIN \
211217
--longoptions=default-exclude,dry-run,fast,skip-scrub,recursive \
212218
--longoptions=event:,keep:,label:,prefix:,sep: \
213219
--longoptions=debug,help,quiet,syslog,verbose \
@@ -536,7 +542,7 @@ SNAPPROP="-o com.sun:auto-snapshot-desc='$opt_event'"
536542

537543
# ISO style date; fifteen characters: YYYY-MM-DD-HHMM
538544
# On Solaris %H%M expands to 12h34.
539-
DATE=$(date --utc +%F-%H%M)
545+
DATE=$(date -u +%F-%H%M)
540546

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

0 commit comments

Comments
 (0)