Skip to content

Commit 2e26499

Browse files
committed
Rebase exit codes to above 127.
Most standard shell utilities return errors less than 128. Rebase the exit codes of this script to reduce the liklihood of overlap.
1 parent f7ceb28 commit 2e26499

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/zfs-auto-snapshot.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ GETOPT=$(getopt \
196196
--longoptions=debug,help,quiet,syslog,verbose \
197197
--options=dnshl:k:p:rs:qgv \
198198
-- "$@" ) \
199-
|| exit 1
199+
|| exit 128
200200

201201
eval set -- "$GETOPT"
202202

@@ -229,7 +229,7 @@ do
229229
if ! test "$2" -gt '0' 2>/dev/null
230230
then
231231
print_log error "The $1 parameter must be a positive integer."
232-
exit 2
232+
exit 129
233233
fi
234234
opt_keep="$2"
235235
shift 2
@@ -245,7 +245,7 @@ do
245245
case $opt_prefix in
246246
([![:alnum:]_-.:\ ]*)
247247
print_log error "The $1 parameter must be alphanumeric."
248-
exit 44
248+
exit 130
249249
;;
250250
esac
251251
opt_prefix="${opt_prefix#?}"
@@ -270,11 +270,11 @@ do
270270
;;
271271
('')
272272
print_log error "The $1 parameter must be non-empty."
273-
exit 3
273+
exit 131
274274
;;
275275
(*)
276276
print_log error "The $1 parameter must be one alphanumeric character."
277-
exit 4
277+
exit 132
278278
;;
279279
esac
280280
opt_sep="$2"
@@ -299,7 +299,7 @@ done
299299
if [ "$#" -eq '0' ]
300300
then
301301
print_log error "The filesystem argument list is empty."
302-
exit 5
302+
exit 133
303303
fi
304304

305305
# Count the number of times '//' appears on the command line.
@@ -312,22 +312,22 @@ done
312312
if [ "$#" -gt '1' -a "$SLASHIES" -gt '0' ]
313313
then
314314
print_log error "The // must be the only argument if it is given."
315-
exit 6
315+
exit 134
316316
fi
317317

318318
# These are the only times that `zpool status` or `zfs list` are invoked, so
319319
# this program for Linux has a much better runtime complexity than the similar
320320
# Solaris implementation.
321321

322322
ZPOOL_STATUS=$(env LC_ALL=C zpool status 2>&1 ) \
323-
|| { print_log error "zpool status $?: $ZPOOL_STATUS"; exit 7; }
323+
|| { print_log error "zpool status $?: $ZPOOL_STATUS"; exit 135; }
324324

325325
ZFS_LIST=$(env LC_ALL=C zfs list -H -t filesystem,volume -s name \
326326
-o name,com.sun:auto-snapshot,com.sun:auto-snapshot:"$opt_label") \
327-
|| { print_log error "zfs list $?: $ZFS_LIST"; exit 8; }
327+
|| { print_log error "zfs list $?: $ZFS_LIST"; exit 136; }
328328

329329
SNAPSHOTS_OLD=$(env LC_ALL=C zfs list -H -t snapshot -S creation -o name) \
330-
|| { print_log error "zfs list $?: $SNAPSHOTS_OLD"; exit 9; }
330+
|| { print_log error "zfs list $?: $SNAPSHOTS_OLD"; exit 137; }
331331

332332

333333
# Verify that each argument is a filesystem or volume.
@@ -341,7 +341,7 @@ do
341341
$ZFS_LIST
342342
HERE
343343
print_log error "$ii is not a ZFS filesystem or volume."
344-
exit 10
344+
exit 138
345345
done
346346

347347
# Get a list of pools that are being scrubbed.

0 commit comments

Comments
 (0)