diff options
author | Bryan Drewery <bryan@shatow.net> | 2021-11-24 08:20:37 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2021-11-24 06:31:11 +0300 |
commit | ab3713fa4a987ded6f2d7207831716bbd904c524 (patch) | |
tree | c8ec87ccc13b739224bfff84ad163b14f1e3e3ad /src/share | |
parent | 77a6100129c82484813a8d971f05820fc095d879 (diff) |
display_output: Strip ansi colors from headers and when sizing fields
Diffstat (limited to 'src/share')
-rw-r--r-- | src/share/poudriere/include/display.sh | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/share/poudriere/include/display.sh b/src/share/poudriere/include/display.sh index 43045a58..d4009e9c 100644 --- a/src/share/poudriere/include/display.sh +++ b/src/share/poudriere/include/display.sh @@ -47,6 +47,7 @@ display_add() { display_output() { local cnt lengths length format arg flag quiet line n + local header header_format local OPTIND=1 quiet=0 @@ -70,13 +71,17 @@ display_output() { n=0 while mapfile_read_loop_redir line; do n=$((n + 1)) - if [ "${n}" -eq 1 -a "${quiet}" -eq 1 ]; then - continue + if [ "${n}" -eq 1 ]; then + if [ "${quiet}" -eq 1 ]; then + continue + fi + header="${line}" fi eval "set -- ${line}" cnt=0 for arg in "$@"; do hash_get lengths ${cnt} max_length || max_length=0 + stripansi "${arg}" arg if [ ${#arg} -gt ${max_length} ]; then # Keep the hash var local to this function _hash_var_name "lengths" "${cnt}" @@ -116,10 +121,10 @@ display_output() { # Show header separately so it is not sorted if [ "${quiet}" -eq 0 ]; then - echo "${_DISPLAY_DATA}"| head -n 1 | while read line; do - eval "set -- ${line}" - printf "${format}\n" "$@" - done + stripansi "${header}" header + stripansi "${format}" header_format + eval "set -- ${header}" + printf "${header_format}\n" "$@" fi # Sort as configured in display_setup() |