diff --git a/rc/core/doc.kak b/rc/core/doc.kak index 4a8e2d4c..1c49f077 100644 --- a/rc/core/doc.kak +++ b/rc/core/doc.kak @@ -5,11 +5,14 @@ def -hidden -params 1..2 doc-open %{ %sh{ manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) - # Those options are handled by the `man-db` implementation + # This option is handled by the `man-db` implementation export MANWIDTH=${kak_window_width} if man "$1" > "${manout}"; then - sed -i "" -e $(printf 's/.\x8//g') -e 's,\x1B\[[0-9;]*[a-zA-Z],,g' "${manout}" + readonly manout_noescape=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) + + sed -e $(printf 's/.\x8//g') -e 's,\x1B\[[0-9;]*[a-zA-Z],,g' "${manout}" > "${manout_noescape}" + mv -f "${manout_noescape}" "${manout}" printf %s\\n " edit! -scratch '*doc*'