Skip to content

Commit 4c14da4

Browse files
committed
Consistently quote literal strings.
Apply some syntax hygiene. Quoting everything is a safe habit because unquoted things can have subtle side-effects.
1 parent 249e6a4 commit 4c14da4

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/zfs-auto-snapshot.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ DESTRUCTION_COUNT='0'
4343
SNAPSHOT_COUNT='0'
4444
WARNING_COUNT='0'
4545

46-
# Global variables.
46+
# Other global variables.
4747
SNAPSHOTS_OLD=''
4848

4949

@@ -125,7 +125,7 @@ do_run () # [argv]
125125
else
126126
eval $*
127127
RC="$?"
128-
if [ "$RC" -eq 0 ]
128+
if [ "$RC" -eq '0' ]
129129
then
130130
print_log debug "$*"
131131
else
@@ -154,9 +154,9 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
154154
do
155155
if do_run "zfs snapshot $PROPERTIES $FLAGS '$ii@$NAME'"
156156
then
157-
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT +1 ))
157+
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
158158
else
159-
WARNING_COUNT=$(( $WARNING_COUNT +1 ))
159+
WARNING_COUNT=$(( $WARNING_COUNT + 1 ))
160160
continue
161161
fi
162162

@@ -172,11 +172,11 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
172172
if [ -z "${jj#$ii@$GLOB}" ]
173173
then
174174
KEEP=$(( $KEEP - 1 ))
175-
if [ "$KEEP" -le 0 ]
175+
if [ "$KEEP" -le '0' ]
176176
then
177177
if do_run "zfs destroy $FLAGS '$jj'"
178178
then
179-
DESTRUCTION_COUNT=$(( $DESTRUCTION_COUNT +1 ))
179+
DESTRUCTION_COUNT=$(( $DESTRUCTION_COUNT + 1 ))
180180
else
181181
WARNING_COUNT=$(( $WARNING_COUNT + 1 ))
182182
fi
@@ -200,13 +200,13 @@ GETOPT=$(getopt \
200200

201201
eval set -- "$GETOPT"
202202

203-
while [ "$#" -gt 0 ]
203+
while [ "$#" -gt '0' ]
204204
do
205205
case "$1" in
206206
(-d|--debug)
207-
opt_debug=1
207+
opt_debug='1'
208208
opt_quiet=''
209-
opt_verbose=1
209+
opt_verbose='1'
210210
shift 1
211211
;;
212212
(--default-exclude)
@@ -218,15 +218,15 @@ do
218218
shift 1
219219
;;
220220
(-s|--skip-scrub)
221-
opt_skip_scrub=1
221+
opt_skip_scrub='1'
222222
shift 1
223223
;;
224224
(-h|--help)
225225
print_usage
226226
exit 0
227227
;;
228228
(-k|--keep)
229-
if ! test "$2" -gt 0 2>/dev/null
229+
if ! test "$2" -gt '0' 2>/dev/null
230230
then
231231
print_log error "The $1 parameter must be a positive integer."
232232
exit 2
@@ -249,7 +249,7 @@ do
249249
shift 1
250250
;;
251251
(-r|--recursive)
252-
opt_recursive=1
252+
opt_recursive='1'
253253
shift 1
254254
;;
255255
(--sep)
@@ -264,18 +264,18 @@ do
264264
(*)
265265
print_log error "The $1 parameter must be one alphanumeric character."
266266
exit 4
267-
;;
267+
;;
268268
esac
269269
opt_sep="$2"
270270
shift 2
271271
;;
272272
(-g|--syslog)
273-
opt_syslog=1
273+
opt_syslog='1'
274274
shift 1
275275
;;
276276
(-v|--verbose)
277277
opt_quiet=''
278-
opt_verbose=1
278+
opt_verbose='1'
279279
shift 1
280280
;;
281281
(--)
@@ -285,7 +285,7 @@ do
285285
esac
286286
done
287287

288-
if [ "$#" -eq 0 ]
288+
if [ "$#" -eq '0' ]
289289
then
290290
print_log error "The filesystem argument list is empty."
291291
exit 5
@@ -298,7 +298,7 @@ do
298298
test "$ii" = '//' && SLASHIES=$(( $SLASHIES + 1 ))
299299
done
300300

301-
if [ "$#" -gt 1 -a "$SLASHIES" -gt 0 ]
301+
if [ "$#" -gt '1' -a "$SLASHIES" -gt '0' ]
302302
then
303303
print_log error "The // must be the only argument if it is given."
304304
exit 6

0 commit comments

Comments
 (0)