Skip to content

Commit

Permalink
realpath(1): add manpages
Browse files Browse the repository at this point in the history
  • Loading branch information
q66 committed Sep 11, 2024
1 parent f30ff3c commit 0b366f0
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src.custom/realpath/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ realpath = executable('realpath', ['realpath.cc'],
install: true
)

install_man('realpath.1')
install_man('readlink.1')

if not chimera_realpath.enabled()
install_symlink('readlink', pointing_to: 'realpath', install_dir: bindir)
endif
58 changes: 58 additions & 0 deletions src.custom/realpath/readlink.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.Dd Sep 11, 2024
.Dt READLINK 1
.Os
.Sh NAME
.Nm readlink
.Nd print symbolic link targets or canonical file names
.Sh SYNOPSIS
.Nm
.Op Ar OPTION...
.Op Ar path...
.Sh DESCRIPTION
The
.Nm
utility by default reads and prints symbolic link names.
It can additionally canonicalize paths, but in general
.Nm realpath
should be preferred for that.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl f, e, -canonicalize, -canonicalize-existing
Instead of reading link target, canonicalize
.Ar path
similarly to the
.Nm readlink
utility. All components must exist.
.It Fl m, -canonicalize-missing
Like above, but no components must exist.
.It Fl n, no-newline
Do not output the trailing newline. This is ignored if
there are multiple inputs.
.It Fl q, s, -quiet, -silent
Most error messages are suppressed. The return failure code is still issued.
This is the default.
.It Fl v, -verbose
Do not suppress error messages.
.It Fl z, -zero
By default, newlines are used to end each output line. With this flag,
NUL is used instead.
.It Fl -help
Display a help message and exit.
.It Fl -version
Display version information and exit.
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr readlink 3 ,
.Xr realpath 1
.Sh HISTORY
On
.Fx
this utility is a special invocation of
.Xr stat 1
and first appeared in
.Fx 4.10 .
This implementation is a part of chimerautils and is a special
invocation of
.Xr realpath 1 .
71 changes: 71 additions & 0 deletions src.custom/realpath/realpath.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.Dd Sep 11, 2024
.Dt REALPATH 1
.Os
.Sh NAME
.Nm realpath
.Nd print the resolved path
.Sh SYNOPSIS
.Nm
.Op Ar OPTION...
.Op Ar path...
.Sh DESCRIPTION
The
.Nm
utility resolve all symbolic links, extra
.Ql /
characters and references to
.Pa /./
and
.Pa /../
in
.Ar path .
If
.Ar path
is absent, the current working directory
.Pq Sq Pa .\&
is assumed.
.Pp
By default, all components of
.Ar path
must exist.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl f, -canonicalize-existing
All components must exist. This is the default behavior.
.It Fl m, -canonicalize-missing
No component of the
.Ar path
must exist. It is resolved up until the first component that exists
and a normalized path is printed.
.It Fl s, -strip, -no-symlinks
The
.Ar path
is normalized logically, without resolving any symlinks.
.It Fl q, -quiet
Most error messages are suppressed. The return failure code is still issued.
.It Fl z, -zero
By default, newlines are used to end each output line. With this flag,
NUL is used instead.
.It Fl -help
Display a help message and exit.
.It Fl -version
Display version information and exit.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Show the physical path of the
.Pa /dev/log
directory silencing warnings if any:
.Bd -literal -offset indent
$ realpath -q /dev/log
/var/run/log
.Ed
.Sh SEE ALSO
.Xr realpath 3
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 4.3 .
This implementation is a part of chimerautils and was written from scratch.

0 comments on commit 0b366f0

Please sign in to comment.