I have the following lftp script to copy files from a remote to local:
env TERM=dumb script -a $LOGSTDOUT -c "$(cat <<- EOF
    lftp $PROTOCOL://$URL -u ${USER},${PASS} << EOFF
    set dns:fatal-timeout never
    set sftp:auto-confirm yes
    set mirror:use-pget-n 50
    set mirror:parallel-transfer-count 2
    set mirror:parallel-directories yes
    set mirror:include-regex $REGEX
    set log:enabled/xfer yes
    set log:file/xfer $LOG
    set xfer:use-temp-file yes
    set xfer:temp-file-name *.lftp
    mirror -c -v --loop --Remove-source-dirs "$REMOTEDIR" "$LOCALDIR"
    quit
    EOFF
EOF
)"
I am capturing terminal output with the script(1) utility. The env TERM=dumb is just a random piece of code I found to disable ANSI escape codes.
My problem is that the line breaks of the output log file get quiet mangled. It seems to be using CR and LF. I discovered more information here and it seems this is by design. Though I'm not sure how to fix it.
These line endings cause issues when viewing the logs in lnav:
The reason for this becomes quickly apparent upon inspecting the raw text:
I have thought of some potential options, but not sure how to implement:
- Fix the output of the - script(1)utility so that single CR are converted to LF. Maybe this can be achieved with piping or some argument?
- A hack for - lnavto treat CR as LF when displaying in the GUI.
Does anyone know how I can fix these line breaks so it shows correctly in lnav?


 
     
    