logoalt Hacker News

fcloudtoday at 4:51 PM5 repliesview on HN

I intended to post in defense of manpages. I love manpages. I think most open-source manpages are high-quality, and a few are really outstanding.

"It's easier to ask an AI" can be true without implying that manpages are bad.

However, "man" the tool does have issues, and one of them bit me just now.

So, I didn't know about openssh client escapes like ~?. I thought, "surely that's in the manpage?" I opened the manpage (in less) and searched for "\~\?". No hits.

Of course, escape characters are documented in the manpage, and the string "~?" does appear. Why didn't search find it? Because man, in its infinite wisdom, decided to render every instance of "~" as some bizarre unicode not-tilde, which is visually similar but totally impossible to grep for.

This has also bitten me in the past with dash. DASH. A character that is critically important when documenting invocation options. man loves to convert it into something that looks like dash, prints like dash, but doesn't come up in search.

I'm sure there is a way to turn this "feature" off, and I'm about to spend a bunch of time figuring out what it is. But this is documentation for command-line tools. Silently destroying our ability to grep it should NOT be the default.


Replies

fdgddtoday at 6:34 PM

I don't know about it changing your characters, but you can search for a string verbatim by pressing ctrl-r at the start of the search pattern, like this:

  /<ctrl-r>~?
layer8today at 5:44 PM

Works for me on Debian (with the default pager, less).

fcloudtoday at 6:26 PM

Thanks for the suggestions. Invoking man with "-E ascii" fixed this for me.

It sounds like some distributions do have this fixed in their default settings. I'm on Cygwin 3.6.6; maybe it's mostly a Cygwin thing.

whydoyoucaretoday at 6:06 PM

\~\? works on macOS, as well as CentOS.

arccytoday at 5:23 PM

with neovim as the pager for man, it does find ~?

though you have to be aware of the escapes for regex, so \~?