]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/functions/functions.util
network fix parameter passing when using ""
[people/stevee/network.git] / src / functions / functions.util
index 018276cc73075bcce24ab2288808fd271bf00f17..24e3e66b1682ed536722744a66a618af2f3f8d01 100644 (file)
@@ -134,7 +134,7 @@ parse_time() {
        local ret=0
 
        local arg
-       for arg in $@; do
+       for arg in "$@"; do
                local unit
 
                case "${arg}" in
@@ -495,7 +495,7 @@ cmd() {
 }
 
 cmd_quiet() {
-       cmd $@ &>/dev/null
+       cmd "$@" &>/dev/null
 }
 
 cmd_exec() {
@@ -515,7 +515,7 @@ cmd_not_implemented() {
 
 # Executes the given command in background
 cmd_background() {
-       cmd_quiet $@ &
+       cmd_quiet "$@" &
 }
 
 # Prints the PID of the process that was started last
@@ -531,7 +531,7 @@ cmd_background_result() {
 
 # Increase security of the read command
 read() {
-       builtin read -r $@
+       builtin read -r "$@"
 }
 
 seq() {
@@ -557,7 +557,7 @@ count() {
 }
 
 which() {
-       type -P $@
+       type -P "$@"
 }
 
 # Prints the number of seconds since epoch.
@@ -607,10 +607,13 @@ beautify_bytes() {
 module_load() {
        local module=${1}
 
-       if ! grep -q "^${module}" /proc/modules; then
-               log DEBUG "Loading module '${module}'."
-               modprobe ${module}
+       # Do nothing if the module is already loaded
+       if [ -d "/sys/module/${module//-/_}" ]; then
+               return ${EXIT_OK}
        fi
+
+       log DEBUG "Loading kernel module ${module}"
+       modprobe "${module}"
 }
 
 binary_exists() {