diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest
index 2c6057d6..f3739f6c 100755
--- a/cdist/conf/type/__hostname/manifest
+++ b/cdist/conf/type/__hostname/manifest
@@ -28,6 +28,8 @@ not_supported() {
 
 
 os=$(cat "$__global/explorer/os")
+max_len=$(cat "$__object/explorer/max_len")
+
 if [ -f "$__object/parameter/name" ]; then
     name_should="$(cat "$__object/parameter/name")"
 else
@@ -45,7 +47,7 @@ else
     esac
 fi
 
-if test -n "${max_len}" -a "$(wc -c "${name_should}")" -gt "${max_len}"a
+if test -n "${max_len}" -a "$(printf "${name_should}" | wc -c)" -gt "${max_len}"
 then
 	printf "Host name too long. Up to %u characters allowed.\n" "${max_len}" >&2
 	exit 1