Skip to main content 41q.ru

Man Глубже Чем Я Думал

Почему-то я думал, что руководства по системным утилитам это простые текстовые файлики, которые лежат где-то в системе. man просто открывает эти файлы и показывает их пользователю.

А они, оказывается, создаются на лету.

MAN(1)

code snippet start

NAME
     man, apropos, whatis – display online manual documentation pages

code snippet end

m a n s h и e с у l п т l о и - л л с ь и к з т р у ы и е п т т N R R E T E P O Q B F I F N L E C F R P o s t s c П r р i е p R T п t O R р F O о ( F F ц ( P F е h S с c a ) с a r о t m р - f ы v u l )

man - это шелл скрипт

sh code snippet start

% which man
/usr/bin/man
% file /usr/bin/man
/usr/bin/man: POSIX shell script text executable, ASCII text
% head -n 7 /usr/bin/man
#! /bin/sh
#
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
#
#  Copyright (c) 2010 Gordon Tetlow
#  All rights reserved.
#
%

sh code snippet end

который использует (/usr/bin/man:479) утилиты

sh code snippet start

...
local _toolpath
for tool in EQN NROFF PIC TBL TROFF REFER VGRIND; do
  eval "_toolpath=\${${tool}}"
...

sh code snippet end

NROFF TROFF TROFF

nroff and the related troff were both developed from the original roff. While nroff was intended to produce output on terminals and line printers, troff was intended to produce output on typesetting systems. Both used the same underlying markup and a single source file could normally be used by nroff or troff without change. [https://en.wikipedia.org/wiki/Nroff](wiki: nroff)

Препроцессоры

EQN NROFF PIC TBL TROFF REFER VGRIND - системные утилиты

Формат файлов

mdoc – semantic markup language for formatting manual pages — man mdoc

code snippet start

% cat /usr/share/man/man1/passwd.1
.\" Copyright (c) 1990, 1993
.\"	The Regents of the University of California.  All rights reserved.
...
.\" SUCH DAMAGE.
.\"
.\"	@(#)passwd.1	8.1 (Berkeley) 6/6/93
.\"
.Dd August 18, 2008
.Dt PASSWD 1
.Os "macOS"
.Sh NAME
.Nm passwd
.Nd modify a user's password
.Sh SYNOPSIS
.Nm passwd
.Op Fl i Ar infosystem Op Fl l Ar location
.Op Fl u Ar authname
...
.Xr passwd 5 ,
.Xr pwd_mkdb 8 ,
.Xr vipw 8
.Rs
.%A Robert Morris
.%A Ken Thompson
.%T "UNIX password security"
.Re
.Sh HISTORY
A
.Nm passwd
command appeared in
.At v6 .

code snippet end