From 9f93af614f7463317ec56af5a6484f66386af797 Mon Sep 17 00:00:00 2001 From: Joern Siglen Date: Tue, 6 Sep 2022 10:55:25 +0200 Subject: [PATCH] dbginfo.sh: ensure compatibility with /bin/dash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit some versions of /bin/dash do interpreted our commands different, which causes a variable failure and termination of the script. e.g. a new line char "\n" will split the cmd_type to a multiple line variable not working with the followup commands. adding the head command does avoid multiline variables now. Problem found in Ubuntu 20.4 and some older Ubuntu versions Reviewed-by: Mario Held Signed-off-by: Joern Siglen Signed-off-by: Jan Höppner --- CHANGELOG.md | 1 + scripts/dbginfo.sh | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b670108c..ed98ab09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Release history for s390-tools (MIT version) Bug Fixes: - dbginfo.sh: save dbginfo.sh version to dbginfo.log + - dbginfo.sh: ensure compatibility with /bin/dash shell * __v2.23.0 (2022-08-18)__ diff --git a/scripts/dbginfo.sh b/scripts/dbginfo.sh index 5705afa0..c4916393 100755 --- a/scripts/dbginfo.sh +++ b/scripts/dbginfo.sh @@ -1160,8 +1160,9 @@ call_run_command() { local rc=0 local cmd="${1}" local logfile="${2}" - # extract the raw_command and set cmd_type - local raw_cmd=$(echo "${cmd}" | sed -ne 's/^\([^[:space:]]*\).*$/\1/p') + # extract the raw_command and set cmd_type, as some shell might split into + # several lines restrict the cmd echo to the first line only + local raw_cmd=$(echo "${cmd}" | head -1 | sed -ne 's/^\([^[:space:]]*\).*$/\1/p') local cmd_type=$(type ${raw_cmd} | cut -d' ' -sf4,5) echo "#######################################################" >> "${logfile}"