overgrown/docs/dj.1

218 lines
4.9 KiB
Groff
Raw Normal View History

.\" Copyright (c) 2024 DTB <trinity@trinity.moe>
.\" Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
.\"
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.TH dj 1
.SH NAME
dj \(en disk jockey
.SH SYNOPSIS
dj
.RB ( -AdHnq )
.RB ( -a
.RB [ byte ])
.RB ( -c
.RB [ count ])
.RB ( -i
.R [
.B input file
.R ])
.RB ( -b
.R [
.B input block size
.R ])
.RB ( -s
.R [
.B input offset
.R ])
.RB ( -o
.R [
.B output file
.R ])
.RB ( -B
.R [
.B output block size
.R ])
.RB ( -S
.R [
.B output offset
.R ])
2024-03-26 23:58:00 -06:00
.SH OPTIONS
2024-04-28 20:42:44 -06:00
.B -i
.RS
2024-05-24 10:03:52 -06:00
Takes a file path as an argument and opens it for use as an input.
2024-04-28 20:42:44 -06:00
.RE
.B -b
.RS
Takes a numeric argument as the size in bytes of the input buffer, with the
2024-05-24 09:53:54 -06:00
default being 1024.
2024-04-28 20:42:44 -06:00
.RE
.B -s
.RS
Takes a numeric argument as the number of bytes to skip into the input
before starting to read. If the standard input is used, bytes read to this point
are discarded.
.RE
.B -o
.RS
2024-05-24 10:06:15 -06:00
Takes a file path as an argument and opens it for use as an output.
.RE
.B -B
.RS
Does the same as
.B -b
but for the output buffer.
.RE
.B -S
.RS
Skips a number of bytes through the output before starting to write from
the input. If the output is a stream, null characters are printed.
.RE
.B -a
.RS
2024-04-18 08:40:29 -06:00
Accepts a single literal byte with which input buffer is padded in the event
of an incomplete read from the input file.
.RE
.B -c
.RS
2024-04-18 08:41:55 -06:00
Specifies a number of reads to make. If set to zero (the default), reading will
continue until a partial or empty read is encountered.
.RE
2024-04-28 20:42:44 -06:00
.B -A
.RS
2024-05-24 09:56:44 -06:00
Specifying this option pads the input buffer with null bytes in the event of an
incomplete read. Equivalent to specifying
2024-04-28 20:42:44 -06:00
.B -a
2024-05-24 09:56:44 -06:00
with a null byte instead of a character.
2024-04-28 20:42:44 -06:00
.RE
.B -d
.RS
2024-03-29 16:14:27 -06:00
Prints invocation information before program execution as described in the
DIAGNOSTICS section below. Each invocation increments the debug level of the
program.
.RE
2024-04-28 20:42:44 -06:00
.B -H
.RS
2024-04-28 20:42:44 -06:00
Prints diagnostics messages in a human-readable manner as described in the
DIAGNOSTICS section below.
.RE
.B -n
.RS
2024-03-27 00:08:43 -06:00
Retries failed reads once more before exiting.
.RE
.B -q
.RS
Suppresses error messages which print when a read or write is partial or
2024-03-27 00:08:43 -06:00
empty. Each invocation decrements the debug level of the program.
.RE
2024-03-27 00:08:43 -06:00
.SH STANDARD INPUT
2024-03-29 16:21:02 -06:00
The standard input shall be used as an input if no inputs are specified one or
more of the input files is “-”.
2024-03-27 00:08:43 -06:00
.SH DIAGNOSTICS
2024-03-29 16:14:27 -06:00
On a partial or empty read, a diagnostic message is printed (unless the
.B -q
2024-03-29 16:14:27 -06:00
option is specified) and the program exits (unless the
.B -n
option is specified.
By default statistics are printed for input and output to the standard error in
the following format:
.RS
.R {records read} {ASCII unit separator} {partial records read}
.R {ASCII record separator} {records written} {ASCII unit separator}
.R {partial records written} {ASCII group separator} {bytes read}
.R {ASCII record separator} {bytes written} {ASCII file separator}
.RE
2024-04-18 08:44:44 -06:00
This format for diagnostic output is designed to be machine-parseable for
convenience. For a more human-readable format, the
.B -H
2024-04-18 08:44:44 -06:00
option may be specified. In this event, the following format is used instead:
.RS
.R {records read} '+' {partial records read} '>' {records written}
.R '+' {partial records written} ';' {bytes read} '>' {bytes written}
.R {ASCII line feed}
.RE
2024-03-29 16:14:27 -06:00
If the
.B -d
option is specified, debug output will be printed at the beginning of execution.
This debug information contains information regarding how the program was
invoked. The following example is the result of running the program with
.B -d
as the only argument:
.RS
.R argv0=dj
.R in=<stdin> ibs=1024 skip=0 align=ff count=0
.R out=<stdout> obs=1024 seek=0 debug= 3 noerror=0
.RE
In non-recoverable errors that dont pertain to the read-write cycle, a
diagnostic message is printed and the program exits with the appropriate
sysexits.h(3) status.
.SH BUGS
If
.B -n
is specified along with a specified count, actual byte output may be lower than
expected (the product of the count multiplied by the input block size). If the
.B -a
or
.B -A
options are used this could make data written nonsensical.
Many lowercase options have capitalized variants and vice-versa which can be
confusing. Capitalized options tend to affect output or are more intense
versions of lowercase options.
2024-03-27 00:08:43 -06:00
.SH CAVEATS
2024-03-27 00:14:02 -06:00
Existing files are not truncated on ouput and are instead overwritten.
2024-03-27 00:08:43 -06:00
.SH RATIONALE
2024-03-26 23:53:10 -06:00
This program was based on the dd(1p) utility as specified in POSIX. While
character conversion may have been the original intent of dd(1p), it is
irrelevant to its modern use. Because of this, it eschews character conversion
and adds typical option formatting, allowing seeks to be specified in bytes
rather than in blocks, allowing arbitrary bytes as padding, and printing in a
format thats easy to parse for machines.
.SH COPYRIGHT
Copyright © 2023 DTB. License AGPLv3+: GNU AGPL version 3 or later
<https://gnu.org/licenses/agpl.html>.
.SH SEE ALSO
dd(1p)