소스 검색

Fix log_loop emitting an empty line on zero output

master
JustAnotherArchivist 1 년 전
부모
커밋
6c6e8281d5
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. +2
    -2
      codearchiver-bot

+ 2
- 2
codearchiver-bot 파일 보기

@@ -27,8 +27,8 @@ function log {

function log_loop {
prefix="$1"
# If the output does not end with a LF, add one. Then replace CRLF with LF and replace remaining CR with LF.
{ lastchar="$(tee /dev/fd/42 | tail -c 1 | xxd -p)"; if [[ "${lastchar}" != '0a' ]]; then printf '\n'; fi } 42>&1 |
# If there is output and it does not end with a LF, add one. Then replace CRLF with LF and replace remaining CR with LF.
{ lastchar="$(tee /dev/fd/42 | tail -c 1 | xxd -p)"; if [[ "${lastchar}" && "${lastchar}" != '0a' ]]; then printf '\n'; fi } 42>&1 |
sed -u 's,\r$,,; s,\r,\n,g' |
while IFS= read -r line; do log "${prefix}${line}"; done
}


불러오는 중...
취소
저장