The problem is the fourth script argument that is the optional user data field.
That field could contain a 254-long string that could include none printable characters as \n.
In the sample code below the script is just interested in the node name that is the second argument. That could not contain any non-printable characters. Therefore none printable characters could be removed for this loop with "tr"
Original code:
for node in "$@"; do
node_name=$(echo "$node" | cut -d"$CLM_IFS" -f2)
echo "$node_name" >> "$nodes_cfg_tmp"
done
Modified code:
//# Temporary remove non-printable characters from input argument
arg_without_newline=$(printf "%s" "$@" | tr -cd '[:print:]')
for node in "$arg_without_newline"; do
node_name=$(echo "$node" | cut -d"$CLM_IFS" -f2)
echo "$node_name" >> "$nodes_cfg_tmp"
done
Diff:
the RS regular expression is perhaps clearer if:
node_name=$(echo "$node" | awk -F "$CLM_IFS" 'BEGIN{RS="^$"} {print $2}')
commit 3c660eef1ad1ca264e1b143151b33378c8f677d2
Author: Hans Nordeback hans.nordeback@ericsson.com
Date: Wed Nov 29 14:44:30 2017 +0100
commit 3d753c5847af88107a9321601263fb03cff6170f
Author: Hans Nordeback hans.nordeback@ericsson.com
Date: Wed Nov 29 14:44:30 2017 +0100