@@ -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
211211function 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
247247function 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
278278function 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
299299function 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() {
335335function 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
400400function 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