From: Michael Tremer Date: Wed, 26 Sep 2012 11:17:35 +0000 (+0000) Subject: Don't strip "" from strings that contain spaces. X-Git-Tag: 005~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f80ce0520f2130ca6c5f898161b823b5591346db;p=network.git Don't strip "" from strings that contain spaces. This confuses the shell because handling variables with spaces in them is horrible. --- diff --git a/functions.config b/functions.config index ab7d9308..9a50de66 100644 --- a/functions.config +++ b/functions.config @@ -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} diff --git a/functions.util b/functions.util index d8880ff4..a7493539 100644 --- a/functions.util +++ b/functions.util @@ -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} +}