]> git.ipfire.org Git - people/ms/network.git/commitdiff
Don't strip "" from strings that contain spaces.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Sep 2012 11:17:35 +0000 (11:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Sep 2012 11:17:35 +0000 (11:17 +0000)
This confuses the shell because handling variables with spaces
in them is horrible.

functions.config
functions.util

index ab7d93082fb40ba3394e117781bfb964fc38130e..9a50de66d5cdf99357677767c5bd0178ca6f9b31 100644 (file)
@@ -105,7 +105,13 @@ function config_read_array() {
 
 # Strip leading and trailing "s.
 function config_strip() {
-       local var=${1}
+       local var="$@"
+
+       # Do nothing for strings that contain spaces.
+       if contains_spaces ${var}; then
+               print "${var}"
+               return ${EXIT_OK}
+       fi
 
        if [ "${var:0:1}" = "\"" ]; then
                var=${var:1}
index d8880ff44b3a81ffab6e5c891132226bf0197a63..a74935398d2104581ac6c86d4b3722b5975b7c88 100644 (file)
@@ -261,6 +261,17 @@ function cmd_quiet() {
        cmd $@ &>/dev/null
 }
 
+function cmd_exec() {
+       local cmd=$@
+
+       log DEBUG "Exec'ing command: ${cmd}"
+
+       exec ${cmd}
+
+       log ERROR "Could not exec-ute: ${cmd}"
+       exit ${EXIT_ERROR}
+}
+
 function seq() {
        if [ $# -eq 2 ]; then
                eval echo {${1}..${2}}
@@ -364,3 +375,16 @@ function network_is_running() {
        # Check, if the network service is running.
        service_is_active network
 }
+
+function contains_spaces() {
+       local var="$@"
+
+       # Eliminate spaces.
+       local var2=${var// /}
+
+       if [ ${#var} -ne ${#var2} ]; then
+               return ${EXIT_TRUE}
+       fi
+
+       return ${EXIT_FALSE}
+}