Bug 1570182 - Escape sequences in man pages when vim is used as manpager
Summary: Escape sequences in man pages when vim is used as manpager
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: man
Version: 31
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Orphan Owner
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-20 20:16 UTC by Sergio Losilla
Modified: 2020-11-24 15:50 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-11-24 15:50:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Sergio Losilla 2018-04-20 20:16:32 UTC
Setting vim as manpager (with MANPAGER "vim -M +MANPAGER -" per the help included in vim) does not work as expected on a fresh install of Fedora 27.

See the bug report I originally filed in vim:

https://github.com/vim/vim/issues/2823

Comment 1 Ben Cotton 2018-11-27 13:55:38 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Ben Cotton 2019-10-31 20:25:13 UTC
This message is a reminder that Fedora 29 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '29'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 29 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Robin A. Meade 2019-11-03 06:43:40 UTC
It's still present.

WORKAROUND #1
=============
Filter out the ansi color sequences using `ansifilter`:

Instead of:

    export MANPAGER="vim -c MANPAGER -"

use:

    export MANPAGER="/bin/sh -c \"ansifilter | vim -c MANPAGER -\""

WORKAROUND #2
=============
Modify /usr/share/vim/vim81/plugin/manpager.vim


diff --git a/manpager.vim b/manpager.vim.new
index dd0d1e8..486a170 100644
--- a/manpager.vim
+++ b/manpager.vim.new
@@ -18,6 +18,9 @@ function! s:ManPager()
   " Emulate 'col -b'
   silent keepj keepp %s/\v(.)\b\ze\1?//ge
 
+  " Remove ansi sequences
+  silent keepj keepp %s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//ge
+
   " Remove empty lines above the header
   call cursor(1, 1)
   let n = search(".*(.*)", "c")


I took the regex from here:
https://github.com/lambdalisue/vim-manpager/commit/65a5d0aee7fe636abb60df30287465ac0660ae43

It was just a guess, but it seems to fix the issue.

SUMMARY
=======

Probably should file an issue against upstream `vim-common` with something like the above change to `/usr/share/vim/vim81/plugin/manpager.vim` to remove the ansi color sequences.

Comment 4 Ben Cotton 2019-11-27 18:15:16 UTC
Fedora 29 changed to end-of-life (EOL) status on 2019-11-26. Fedora 29 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 5 Sergio Losilla 2019-11-27 18:28:37 UTC
The bug is still present.

Comment 6 Ben Cotton 2020-11-03 15:00:35 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Sergio Losilla 2020-11-07 08:02:39 UTC
This is fixed as of Fedora 33, if I recall correctly also on Fedora 32.

Comment 8 Robin A. Meade 2020-11-07 09:19:03 UTC
The bug is still present on Fedora 32 and Fedora 33.

Steps to reproduce the bug:


    # As vim documentation says:
    export MANPAGER="vim -M +MANPAGER -"
    
    # Try a man page
    man git

Result:


    GIT(1)                            Git Manual                            GIT(1)

    ^[[1mNAME^[[0m
           git - the stupid content tracker
    
    ^[[1mSYNOPSIS^[[0m
          ^[[4mgit^[[24m [--version] [--help] [-C <path>] [-c <name>=<value>]


Only if I do:

     export GROFF_NO_SGR=1

or one of the two workarounds of Comment 3 do I get the expected result of no strange escape sequences being visible.

Comment 9 Sergio Losilla 2020-11-07 09:34:59 UTC
My apologies! I had forgotten I had set GROFF_NO_SGR, and looked only at MANPAGER. Indeed unsetting GROFF_NO_SGR triggers the bug, I could reproduce.

Comment 10 Ben Cotton 2020-11-24 15:50:53 UTC
Fedora 31 changed to end-of-life (EOL) status on 2020-11-24. Fedora 31 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.