[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TAB character in groff output

From: Alejandro Colomar
Subject: Re: TAB character in groff output
Date: Tue, 2 Aug 2022 17:14:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0

Hi Ingo,

On 8/2/22 15:44, Ingo Schwarze wrote:
Hi Alejandro,

Alejandro Colomar wrote on Tue, Aug 02, 2022 at 02:14:58PM +0200:

I'd like to be able to produce ASCII HT ('\t' - horizontal tab) in man
pages output.  I don't want to align things; I do want a tab character.
Rationale: examples in fstab(5).

I don't understand.  On Debian, fstab(5) is part of the "mount"
package - which seems very reasonable to me - and it says:

Ahh, I was talking a bit from memory. It wasn't fstab(5), but spufs(7), which has an example of an fstab entry:

       /etc/fstab  entry
              none      /spu      spufs     gid=spu   0    0

   Fields on each line are separated by tabs or spaces.

What's wrong with using spaces?

Nothing very wrong. I was just wondering if tabs were possible. fstab(5) might accept spaces (although I wouldn't use them in a real fstab file, actually; and I guess you can only use single spaces, or maybe not... never tried), but maybe some other software doesn't.

Wanting to show literal tab characters to users in a manual page
seems a dubious goal to me for two reasons:

  * They are visually indistinguishable from spaces, so if the
    distinction really matters, confusion is almost guaranteed to ensue.

Of course, if it matters, some description about it is needed.

  * Some users may use pagers that convert tabs to spaces or vice
    versa, so even if you hope for pastability, you still need
    luck for it to work as intended.

Yeah, I wanted this. But, less(1) doesn't seem to like tabs :(, the same as mandoc(1). The first time I like more(1) better than less(1); of course it has at least one more feature ;)

Is that possible?  I didn't find anything in groff_char(7).

In groff, this works for me:

  $ printf "a\\\\N'9'b" | groff -T ascii | hexdump -C | head -n 1
00000000  61 09 62 0a 0a 0a 0a 0a  0a 0a 0a 0a 0a 0a 0a 0a  |a.b.............|

Mandoc behaves differently and treats \N'9' exactly like a literal HT:

  $ printf "a\\\\N'9'b" | mandoc | hexdump -C | grep 61
00000050  61 20 20 20 20 62 0a 0a  20 20 20 20 20 20 20 20  |a    b..        |

In general, mandoc lets fewer control characters sneak through into
output than groff because i worry that control characters in output
might occasionally cause reliability or security issues.

I have to fix some warnings:

$ make lint-man-mandoc
LINT (mandoc)   tmp/lint/man7/spufs.7.lint-man.mandoc.touch
mandoc: man7/spufs.7:748:7: WARNING: tab in filled text
mandoc: man7/spufs.7:748:14: WARNING: tab in filled text
mandoc: man7/spufs.7:748:22: WARNING: tab in filled text
mandoc: man7/spufs.7:748:32: WARNING: tab in filled text
mandoc: man7/spufs.7:748:34: WARNING: tab in filled text
make: *** [lib/ tmp/lint/man7/spufs.7.lint-man.mandoc.touch] Error 2

In the following code:

$ sed -n 745,749p <man7/spufs.7
.IR /etc/fstab "  entry"
none    /spu    spufs   gid=spu         0       0

$ sed -n 748p <man7/spufs.7
none    /spu    spufs   gid=spu         0       0

$ sed -n 748p <man7/spufs.7 | hexdump -C
00000000 6e 6f 6e 65 20 20 09 2f 73 70 75 20 20 09 73 70 |none ./spu .sp| 00000010 75 66 73 20 20 09 67 69 64 3d 73 70 75 20 20 09 |ufs .gid=spu .|
00000020  30 09 30 0a                                       |0.0.|

That code is very broken: SP SP HT sequences

I think I'll fix it with tbl(1).




Alejandro Colomar

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]