MANPAGER="grep -F {" man systemd.exec leads to man: command exited with status 1: sed -e ...

Bug #1932084 reported by Seth Arnold
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
man-db (Ubuntu)
Triaged
Low
Unassigned

Bug Description

Hello, I wanted to search the systemd.exec(5) manpage for an opening brace character, {, in a manner that would be easy to copy-and-paste the results if there were any. This unfortunately gives an error message:

$ MANPAGER="grep -F {" man systemd.exec
man: command exited with status 1: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page systemd\.exec(5) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page systemd\.exec(5) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=systemd\.exec(5) grep -F {
$ MANPAGER="grep -F {" man apparmor
               profile foo flags=(audit) { ... }
$

It works fine on a simple example, apparmor(7). Other patterns work with systemd.exec(5):

$ MANPAGER="grep -F aa" man systemd.exec
               StateDirectory=aaa/bbb ccc
           then the environment variable "RUNTIME_DIRECTORY" is set with "/run/foo/bar", and "STATE_DIRECTORY" is set with "/var/lib/aaa/bbb:/var/lib/ccc".
$

Thus I think when the pager doesn't provide any output we get an ugly error message. I expected no output at all if the pattern doesn't match.

Thanks

And now the --debug output:

$ MANPAGER="grep -F {" man --debug -s 5 systemd.exec
ruid=1000, euid=1000
rgid=1000, egid=1000
++priv_drop_count = 1
From the config file /etc/manpath.config:
  Mandatory mandir `/usr/man'.
  Mandatory mandir `/usr/share/man'.
  Mandatory mandir `/usr/local/share/man'.
  Path `/bin' mapped to mandir `/usr/share/man'.
  Path `/usr/bin' mapped to mandir `/usr/share/man'.
  Path `/sbin' mapped to mandir `/usr/share/man'.
  Path `/usr/sbin' mapped to mandir `/usr/share/man'.
  Path `/usr/local/bin' mapped to mandir `/usr/local/man'.
  Path `/usr/local/bin' mapped to mandir `/usr/local/share/man'.
  Path `/usr/local/sbin' mapped to mandir `/usr/local/man'.
  Path `/usr/local/sbin' mapped to mandir `/usr/local/share/man'.
  Path `/usr/X11R6/bin' mapped to mandir `/usr/X11R6/man'.
  Path `/usr/bin/X11' mapped to mandir `/usr/X11R6/man'.
  Path `/usr/games' mapped to mandir `/usr/share/man'.
  Path `/opt/bin' mapped to mandir `/opt/man'.
  Path `/opt/sbin' mapped to mandir `/opt/man'.
  Global mandir `/usr/man', catdir `/var/cache/man/fsstnd'.
  Global mandir `/usr/share/man', catdir `/var/cache/man'.
  Global mandir `/usr/local/man', catdir `/var/cache/man/oldlocal'.
  Global mandir `/usr/local/share/man', catdir `/var/cache/man/local'.
  Global mandir `/usr/X11R6/man', catdir `/var/cache/man/X11R6'.
  Global mandir `/opt/man', catdir `/var/cache/man/opt'.
  Global mandir `/snap/man', catdir `/var/cache/man/snap'.
  Added sections: `1', `n', `l', `8', `3', `2', `3posix', `3pm', `3perl', `3am', `5', `4', `9', `6', `7'.
is a tty
using grep -F { as pager
path directory /home/sarnold/bin is not in the config file
path directory /usr/local/sbin is in the config file
  adding /usr/local/man to manpath
  adding /usr/local/share/man to manpath
path directory /usr/local/bin is in the config file
path directory /usr/sbin is in the config file
  adding /usr/share/man to manpath
path directory /usr/bin is in the config file
path directory /sbin is in the config file
path directory /bin is in the config file
path directory /usr/games is in the config file
path directory /usr/local/games is not in the config file
path directory /snap/bin is not in the config file
adding mandatory man directories
warning: /usr/man: No such file or directory
add_nls_manpaths(): processing /usr/local/man:/usr/local/share/man:/usr/share/man
checking for locale en_US.UTF-8
adding /usr/local/man to manpathlist
adding /usr/share/man to manpathlist
final search path = /usr/local/man:/usr/share/man
--priv_drop_count = 0
searching in /usr/local/man, section 5
trying section 5 with globbing
Layout is GNU (1)
update_directory_cache /usr/local/man: miss
globbing pattern in /usr/local/man: man5*
update_directory_cache /usr/local/man: hit
globbing pattern in /usr/local/man: cat5*
Failed to open /var/cache/man/oldlocal/index.db O_RDONLY
searching in /usr/share/man, section 5
trying section 5 with globbing
update_directory_cache /usr/share/man: miss
globbing pattern in /usr/share/man: man5*
matched: /usr/share/man/man5
update_directory_cache /usr/share/man/man5: miss
globbing pattern in /usr/share/man/man5: systemd.exec.5*
matched: /usr/share/man/man5/systemd.exec.5.gz

ult_src: File /usr/share/man/man5/systemd.exec.5.gz in mantree /usr/share/man
loading seccomp filter (permissive: 0)
candidate: 0 0 systemd.exec /usr/share/man /usr/share/man/man5/systemd.exec.5.gz A - 5 5
Checking physical location: /usr/share/man/man5/systemd.exec.5.gz

ult_src: File /usr/share/man/man5/systemd.exec.5.gz in mantree /usr/share/man
loading seccomp filter (permissive: 0)
found ultimate source file /usr/share/man/man5/systemd.exec.5.gz
converted /usr/share/man/man5/systemd.exec.5.gz to /usr/share/man/cat5/systemd.exec.5.gz
is_changed: a=/usr/share/man/man5/systemd.exec.5.gz, b=/usr/share/man/cat5/systemd.exec.5.gz (-2)
converted /var/cache/man/cat5/systemd.exec.5.gz to /var/cache/man/cat5/systemd.exec.5.gz
will try cat file /var/cache/man/cat5/systemd.exec.5.gz
loading seccomp filter (permissive: 0)
pre-processors `t' from file
page_encoding = ISO-8859-1
source_encoding = ISO-8859-1
locale_charset = UTF-8
roff_device (locale) = utf8
roff_encoding = ISO-8859-1
output_encoding = UTF-8
less_charset = utf-8
Terminal width 172
Terminal width 172 not within cat page range [80, 80]
Using 167-character lines
formatted_encoding = UTF-8
format: 1, save_cat: 0, found: 1
add_output_iconv: source UTF-8, target UTF-8
Setting LESS to -ix8RmPm Manual page systemd\.exec(5) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page systemd\.exec(5) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$
Setting MAN_PN to systemd\.exec(5)
++priv_drop_count = 1
man: command exited with status 1: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page systemd\.exec(5) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page systemd\.exec(5) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=systemd\.exec(5) grep -F {
$

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: man-db 2.9.1-1
ProcVersionSignature: Ubuntu 5.4.0-74.83-generic 5.4.114
Uname: Linux 5.4.0-74-generic x86_64
NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair
ApportVersion: 2.20.11-0ubuntu27.18
Architecture: amd64
CasperMD5CheckResult: skip
Date: Wed Jun 16 00:15:22 2021
SourcePackage: man-db
UpgradeStatus: Upgraded to focal on 2020-01-24 (508 days ago)

Revision history for this message
Seth Arnold (seth-arnold) wrote :
Revision history for this message
Colin Watson (cjwatson) wrote :

The problem with fixing this as you describe ("no output at all") is that it would make it difficult to understand what's going on in the more common case where your configured pager is accidentally not installed. Would you accept a less ugly error message (somehow)?

Revision history for this message
Seth Arnold (seth-arnold) wrote :

Hi Colin,

First, re-reading my report, I'm afraid that maybe "{" is used as a shell meta-character, or sed meta-character, or something similar. It might be more than just "no output causes problems". I shouldn't have jumped to conclusions so quickly.

Second, yes, "less ugly [but still useful]" would be great. I hadn't considered the case of the pager missing entirely. Debugging that without help from man would definitely take extra effort.

Thanks

Colin Watson (cjwatson)
Changed in man-db (Ubuntu):
status: New → Triaged
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.