Skip to content

Commit 7740ba0

Browse files
committed
Remove some unnecessary quoting
1 parent c98a72f commit 7740ba0

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

script.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ function parse_params() {
4040
exit 0
4141
;;
4242
-v|--verbose)
43-
verbose="true"
43+
verbose=true
4444
;;
4545
-nc|--no-colour)
46-
no_colour="true"
46+
no_colour=true
4747
;;
4848
-cr|--cron)
49-
cron="true"
49+
cron=true
5050
;;
5151
*)
5252
script_exit "Invalid parameter was provided: $param" 2
@@ -62,8 +62,8 @@ function main() {
6262
# shellcheck source=source.sh
6363
source "$(dirname "${BASH_SOURCE[0]}")/source.sh"
6464

65-
trap "script_trap_err" ERR
66-
trap "script_trap_exit" EXIT
65+
trap script_trap_err ERR
66+
trap script_trap_exit EXIT
6767

6868
script_init "$@"
6969
parse_params "$@"

source.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function script_exit() {
8787
fi
8888
fi
8989

90-
script_exit "Invalid arguments passed to script_exit()!" 2
90+
script_exit 'Invalid arguments passed to script_exit()!' 2
9191
}
9292

9393

@@ -206,7 +206,7 @@ function cron_init() {
206206
# $3 (optional): Set to any value to not append a new line to the message
207207
function pretty_print() {
208208
if [[ $# -eq 0 || $# -gt 3 ]]; then
209-
script_exit "Invalid arguments passed to pretty_print()!" 2
209+
script_exit 'Invalid arguments passed to pretty_print()!' 2
210210
fi
211211

212212
if [[ -z ${no_colour-} ]]; then
@@ -242,7 +242,7 @@ function verbose_print() {
242242
# NOTE: Heavily inspired by: https://unix.stackexchange.com/a/40973
243243
function build_path() {
244244
if [[ -z ${1-} || $# -gt 2 ]]; then
245-
script_exit "Invalid arguments passed to build_path()!" 2
245+
script_exit 'Invalid arguments passed to build_path()!' 2
246246
fi
247247

248248
local new_path path_entry temp_path
@@ -273,7 +273,7 @@ function build_path() {
273273
# $2 (optional): Set to any value to treat failure as a fatal error
274274
function check_binary() {
275275
if [[ $# -ne 1 && $# -ne 2 ]]; then
276-
script_exit "Invalid arguments passed to check_binary()!" 2
276+
script_exit 'Invalid arguments passed to check_binary()!' 2
277277
fi
278278

279279
if ! command -v "$1" > /dev/null 2>&1; then
@@ -294,33 +294,33 @@ function check_binary() {
294294
# ARGS: $1 (optional): Set to any value to not attempt root access via sudo
295295
function check_superuser() {
296296
if [[ $# -gt 1 ]]; then
297-
script_exit "Invalid arguments passed to check_superuser()!" 2
297+
script_exit 'Invalid arguments passed to check_superuser()!' 2
298298
fi
299299

300300
local superuser test_euid
301301
if [[ $EUID -eq 0 ]]; then
302-
superuser="true"
302+
superuser=true
303303
elif [[ -z ${1-} ]]; then
304304
if check_binary sudo; then
305-
pretty_print "Sudo: Updating cached credentials ..."
305+
pretty_print 'Sudo: Updating cached credentials ...'
306306
if ! sudo -v; then
307307
verbose_print "Sudo: Couldn't acquire credentials ..." \
308308
"${fg_red-}"
309309
else
310310
test_euid="$(sudo -H -- "$BASH" -c 'printf "%s" "$EUID"')"
311311
if [[ $test_euid -eq 0 ]]; then
312-
superuser="true"
312+
superuser=true
313313
fi
314314
fi
315315
fi
316316
fi
317317

318318
if [[ -z ${superuser-} ]]; then
319-
verbose_print "Unable to acquire superuser credentials." "${fg_red-}"
319+
verbose_print 'Unable to acquire superuser credentials.' "${fg_red-}"
320320
return 1
321321
fi
322322

323-
verbose_print "Successfully acquired superuser credentials."
323+
verbose_print 'Successfully acquired superuser credentials.'
324324
return 0
325325
}
326326

@@ -331,12 +331,12 @@ function check_superuser() {
331331
function run_as_root() {
332332
local try_sudo
333333
if [[ ${1-} =~ ^0$ ]]; then
334-
try_sudo="true"
334+
try_sudo=true
335335
shift
336336
fi
337337

338338
if [[ $# -eq 0 ]]; then
339-
script_exit "Invalid arguments passed to run_as_root()!" 2
339+
script_exit 'Invalid arguments passed to run_as_root()!' 2
340340
fi
341341

342342
if [[ $EUID -eq 0 ]]; then

template.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function script_exit() {
9191
fi
9292
fi
9393

94-
script_exit "Invalid arguments passed to script_exit()!" 2
94+
script_exit 'Invalid arguments passed to script_exit()!' 2
9595
}
9696

9797

@@ -210,7 +210,7 @@ function cron_init() {
210210
# $3 (optional): Set to any value to not append a new line to the message
211211
function pretty_print() {
212212
if [[ $# -eq 0 || $# -gt 3 ]]; then
213-
script_exit "Invalid arguments passed to pretty_print()!" 2
213+
script_exit 'Invalid arguments passed to pretty_print()!' 2
214214
fi
215215

216216
if [[ -z ${no_colour-} ]]; then
@@ -246,7 +246,7 @@ function verbose_print() {
246246
# NOTE: Heavily inspired by: https://unix.stackexchange.com/a/40973
247247
function build_path() {
248248
if [[ -z ${1-} || $# -gt 2 ]]; then
249-
script_exit "Invalid arguments passed to build_path()!" 2
249+
script_exit 'Invalid arguments passed to build_path()!' 2
250250
fi
251251

252252
local new_path path_entry temp_path
@@ -277,7 +277,7 @@ function build_path() {
277277
# $2 (optional): Set to any value to treat failure as a fatal error
278278
function check_binary() {
279279
if [[ $# -ne 1 && $# -ne 2 ]]; then
280-
script_exit "Invalid arguments passed to check_binary()!" 2
280+
script_exit 'Invalid arguments passed to check_binary()!' 2
281281
fi
282282

283283
if ! command -v "$1" > /dev/null 2>&1; then
@@ -298,33 +298,33 @@ function check_binary() {
298298
# ARGS: $1 (optional): Set to any value to not attempt root access via sudo
299299
function check_superuser() {
300300
if [[ $# -gt 1 ]]; then
301-
script_exit "Invalid arguments passed to check_superuser()!" 2
301+
script_exit 'Invalid arguments passed to check_superuser()!' 2
302302
fi
303303

304304
local superuser test_euid
305305
if [[ $EUID -eq 0 ]]; then
306-
superuser="true"
306+
superuser=true
307307
elif [[ -z ${1-} ]]; then
308308
if check_binary sudo; then
309-
pretty_print "Sudo: Updating cached credentials ..."
309+
pretty_print 'Sudo: Updating cached credentials ...'
310310
if ! sudo -v; then
311311
verbose_print "Sudo: Couldn't acquire credentials ..." \
312312
"${fg_red-}"
313313
else
314314
test_euid="$(sudo -H -- "$BASH" -c 'printf "%s" "$EUID"')"
315315
if [[ $test_euid -eq 0 ]]; then
316-
superuser="true"
316+
superuser=true
317317
fi
318318
fi
319319
fi
320320
fi
321321

322322
if [[ -z ${superuser-} ]]; then
323-
verbose_print "Unable to acquire superuser credentials." "${fg_red-}"
323+
verbose_print 'Unable to acquire superuser credentials.' "${fg_red-}"
324324
return 1
325325
fi
326326

327-
verbose_print "Successfully acquired superuser credentials."
327+
verbose_print 'Successfully acquired superuser credentials.'
328328
return 0
329329
}
330330

@@ -335,12 +335,12 @@ function check_superuser() {
335335
function run_as_root() {
336336
local try_sudo
337337
if [[ ${1-} =~ ^0$ ]]; then
338-
try_sudo="true"
338+
try_sudo=true
339339
shift
340340
fi
341341

342342
if [[ $# -eq 0 ]]; then
343-
script_exit "Invalid arguments passed to run_as_root()!" 2
343+
script_exit 'Invalid arguments passed to run_as_root()!' 2
344344
fi
345345

346346
if [[ $EUID -eq 0 ]]; then
@@ -379,13 +379,13 @@ function parse_params() {
379379
exit 0
380380
;;
381381
-v|--verbose)
382-
verbose="true"
382+
verbose=true
383383
;;
384384
-nc|--no-colour)
385-
no_colour="true"
385+
no_colour=true
386386
;;
387387
-cr|--cron)
388-
cron="true"
388+
cron=true
389389
;;
390390
*)
391391
script_exit "Invalid parameter was provided: $param" 2
@@ -398,8 +398,8 @@ function parse_params() {
398398
# DESC: Main control flow
399399
# ARGS: $@ (optional): Arguments provided to the script
400400
function main() {
401-
trap "script_trap_err" ERR
402-
trap "script_trap_exit" EXIT
401+
trap script_trap_err ERR
402+
trap script_trap_exit EXIT
403403

404404
script_init "$@"
405405
parse_params "$@"

0 commit comments

Comments
 (0)