From d8e98b6cbc4ef93e39a71e16dc3b1c2dcd3c11fd Mon Sep 17 00:00:00 2001 From: Ondrej Famera Date: Sun, 8 Dec 2019 17:50:07 +0900 Subject: [PATCH] strip newline from all passed variables this prevents weird errors whem attributes get shifted to newline and executed by docker-entrypoint.sh When newline is stripped a 'Warning' is printed --- 5.6/docker-entrypoint.sh | 6 ++++++ 5.7/docker-entrypoint.sh | 6 ++++++ 8.0/docker-entrypoint.sh | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/5.6/docker-entrypoint.sh b/5.6/docker-entrypoint.sh index 6f0f1316f..d49f92f9f 100755 --- a/5.6/docker-entrypoint.sh +++ b/5.6/docker-entrypoint.sh @@ -35,6 +35,12 @@ file_env() { elif [ "${!fileVar:-}" ]; then val="$(< "${!fileVar}")" fi + # remove newline from values which would cause troubles later if present + new_val=$(echo "$val"|tr -d '\n') + if [ "$new_val" != "$val" ]; then + mysql_warn "Stripping newline from ${var}." + val="$new_val" + fi export "$var"="$val" unset "$fileVar" } diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index 6f0f1316f..d49f92f9f 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -35,6 +35,12 @@ file_env() { elif [ "${!fileVar:-}" ]; then val="$(< "${!fileVar}")" fi + # remove newline from values which would cause troubles later if present + new_val=$(echo "$val"|tr -d '\n') + if [ "$new_val" != "$val" ]; then + mysql_warn "Stripping newline from ${var}." + val="$new_val" + fi export "$var"="$val" unset "$fileVar" } diff --git a/8.0/docker-entrypoint.sh b/8.0/docker-entrypoint.sh index 6f0f1316f..d49f92f9f 100755 --- a/8.0/docker-entrypoint.sh +++ b/8.0/docker-entrypoint.sh @@ -35,6 +35,12 @@ file_env() { elif [ "${!fileVar:-}" ]; then val="$(< "${!fileVar}")" fi + # remove newline from values which would cause troubles later if present + new_val=$(echo "$val"|tr -d '\n') + if [ "$new_val" != "$val" ]; then + mysql_warn "Stripping newline from ${var}." + val="$new_val" + fi export "$var"="$val" unset "$fileVar" }