Skip to content

Commit

Permalink
Merge pull request #363 from m-1-k-3/printer
Browse files Browse the repository at this point in the history
Print function fix
  • Loading branch information
BenediktMKuehne authored Oct 24, 2022
2 parents ac234dd + 9a47e60 commit 5f211dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions helpers/helpers_emba_html_generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ generate_report_file()

sed -i -E -e "s:[=]{65}:$HR_DOUBLE:g ; s:^[-]{65}$:$HR_MONO:g" "$TMP_FILE" || true
sed -i -e "s:^:$P_START: ; s:$:$P_END:" "$TMP_FILE" || true
# this fixes the </pre> lines instead of <pre></pre> - something weird with \r\n
sed -i -E "s:\r$P_END:$P_END:" "$TMP_FILE" || true

# add html tags for style
add_color_tags "$TMP_FILE"
Expand Down Expand Up @@ -608,9 +610,9 @@ scan_report()
{
# at the end of an EMBA run, we have to disable all non-valid links to modules
local LINK_ARR
readarray -t LINK_ARR < <(grep -a -R -E "class\=\"refmodul\" href=\"(.*)" "$ABS_HTML_PATH" | cut -d"\"" -f 4 | cut -d"#" -f 1 | sort -u)
readarray -t LINK_ARR < <(grep -a -R -E "class\=\"refmodul\" href=\"(.*)" "$ABS_HTML_PATH" | cut -d"\"" -f 4 | cut -d"#" -f 1 | sort -u || true)
local LINK_FILE_ARR
readarray -t LINK_FILE_ARR < <(grep -a -R -E -l "class\=\"refmodul\" href=\"(.*)" "$ABS_HTML_PATH")
readarray -t LINK_FILE_ARR < <(grep -a -R -E -l "class\=\"refmodul\" href=\"(.*)" "$ABS_HTML_PATH" || true)
for LINK in "${LINK_ARR[@]}" ; do
for FILE in "${LINK_FILE_ARR[@]}" ; do
if ! [[ -f "$ABS_HTML_PATH""/""$LINK" ]] ; then
Expand Down
14 changes: 7 additions & 7 deletions helpers/helpers_emba_print.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ print_output()
# add a link as third argument to add a link marker for web report
local REF_LINK="${3:-}"
local TYPE_CHECK
TYPE_CHECK="$( safe_echo "$OUTPUT" | cut -c1-3 )"
TYPE_CHECK="$( echo "$OUTPUT" | cut -c1-3 )"
if [[ "$TYPE_CHECK" == "[-]" || "$TYPE_CHECK" == "[*]" || "$TYPE_CHECK" == "[!]" || "$TYPE_CHECK" == "[+]" ]] ; then
local COLOR_OUTPUT_STRING=""
COLOR_OUTPUT_STRING="$(color_output "$OUTPUT")"
Expand All @@ -119,9 +119,9 @@ print_output()
safe_echo "$(format_log "$COLOR_OUTPUT_STRING")" "$LOG_FILE_MOD"
fi
else
safe_echo "$(format_log "$COLOR_OUTPUT_STRING")""\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE"
safe_echo "$(format_log "$COLOR_OUTPUT_STRING")""\\r\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE"
if [[ -n "${LOG_FILE_MOD:-}" ]]; then
safe_echo "$(format_log "$COLOR_OUTPUT_STRING")""\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE_MOD"
safe_echo "$(format_log "$COLOR_OUTPUT_STRING")""\\r\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE_MOD"
fi
fi
fi
Expand All @@ -136,9 +136,9 @@ print_output()
safe_echo "$(format_log "$OUTPUT")" "$LOG_FILE_MOD"
fi
else
safe_echo "$(format_log "$OUTPUT")""\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE"
safe_echo "$(format_log "$OUTPUT")""\\r\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE"
if [[ -n "${LOG_FILE_MOD:-}" ]]; then
safe_echo "$(format_log "$OUTPUT")""\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE_MOD"
safe_echo "$(format_log "$OUTPUT")""\\r\\n""$(format_log "[REF] ""$REF_LINK" 1)" "$LOG_FILE_MOD"
fi
fi
fi
Expand All @@ -155,9 +155,9 @@ safe_echo() {
# %b ARGUMENT as a string with '\' escapes interpreted, except that octal escapes are of the form \0 or
if [[ -v 2 ]]; then
local LOG_TO_FILE="${2:-}"
printf -- "%b" "$STRING_TO_ECHO\n" | tee -a "$LOG_TO_FILE" >/dev/null || true
printf -- "%b" "$STRING_TO_ECHO\r\n" | tee -a "$LOG_TO_FILE" >/dev/null || true
else
printf -- "%b" "$STRING_TO_ECHO\n" || true
printf -- "%b" "$STRING_TO_ECHO\r\n" || true
fi
}

Expand Down

0 comments on commit 5f211dd

Please sign in to comment.