2024-02-01 20:40:50 -07:00
|
|
|
|
.\" Copyright (c) 2023–2024 DTB <trinity@trinity.moe>
|
2024-03-26 18:26:51 -06:00
|
|
|
|
.\" Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.\"
|
|
|
|
|
.\" 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/>.
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.\"
|
2024-06-21 03:23:39 -06:00
|
|
|
|
.TH INTCMP 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH NAME
|
|
|
|
|
intcmp \(en compare integers
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.\"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH SYNOPSIS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
|
2023-12-24 17:13:17 -07:00
|
|
|
|
intcmp
|
2024-03-26 18:26:51 -06:00
|
|
|
|
.RB ( -egl )
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.RB [ integer ]
|
|
|
|
|
.RB [ integer... ]
|
|
|
|
|
.SH DESCRIPTION
|
2024-03-29 16:22:56 -06:00
|
|
|
|
Compare integers to each other.
|
2024-06-03 23:07:19 -06:00
|
|
|
|
.\"
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.SH OPTIONS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.IP \fB-e\fP
|
2024-04-18 08:36:01 -06:00
|
|
|
|
Permits given integers to be equal to each other.
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.IP \fB-g\fP
|
2024-03-26 18:26:51 -06:00
|
|
|
|
Permits a given integer to be greater than the following integer.
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.IP \fB-l\fP
|
2024-03-26 18:26:51 -06:00
|
|
|
|
Permits a given integer to be less than the following integer.
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.\"
|
2024-06-03 23:07:19 -06:00
|
|
|
|
.SH EXAMPLES
|
|
|
|
|
|
2024-06-17 23:27:19 -06:00
|
|
|
|
It may help to think of the
|
|
|
|
|
.BR -e ,
|
|
|
|
|
.BR -g ,
|
|
|
|
|
and
|
|
|
|
|
.B -l
|
|
|
|
|
options as equivalent to the infix algebraic \(lq=\(rq, \(lq>\(rq, and \(lq<\(rq
|
|
|
|
|
operators respectively, with each option putting its symbol between every given
|
|
|
|
|
integer. The following example is equivalent to evaluating \(lq1 < 2 < 3\(rq:
|
2024-06-04 16:11:33 -06:00
|
|
|
|
\"
|
2024-03-26 18:26:51 -06:00
|
|
|
|
.RS
|
2024-06-17 23:27:19 -06:00
|
|
|
|
intcmp -l 1 2 3
|
2024-03-26 18:26:51 -06:00
|
|
|
|
.RE
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.\"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH DIAGNOSTICS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
|
2024-06-17 23:27:19 -06:00
|
|
|
|
The program will exit with a successfully for a valid expression and with an
|
|
|
|
|
error code of 1 for an invalid expression.
|
2024-03-26 18:26:51 -06:00
|
|
|
|
|
2024-03-26 19:22:30 -06:00
|
|
|
|
In the event of an error, a debug message will be printed and the program will
|
2024-06-02 18:47:14 -06:00
|
|
|
|
exit with the appropriate
|
|
|
|
|
.BR sysexits.h (3)
|
|
|
|
|
error code.
|
|
|
|
|
.\"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH BUGS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
|
2024-06-17 23:27:19 -06:00
|
|
|
|
.BR -egl ,
|
|
|
|
|
\(lqequal to or less than or greater than\(rq, always exits successfully for
|
2024-06-02 18:47:14 -06:00
|
|
|
|
valid program usage and may be abused to function as an integer validator. Use
|
|
|
|
|
.BR str (1)
|
|
|
|
|
instead.
|
|
|
|
|
.\"
|
|
|
|
|
.SH CAVEATS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
|
2024-06-02 18:47:14 -06:00
|
|
|
|
There are multiple ways to express compound comparisons; \(lqless than or equal
|
2024-06-17 23:27:19 -06:00
|
|
|
|
to\(rq can be
|
|
|
|
|
.B -le
|
|
|
|
|
or
|
|
|
|
|
.BR -el ,
|
|
|
|
|
for example.
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
2024-06-17 23:27:19 -06:00
|
|
|
|
The inequality comparison is
|
|
|
|
|
.B -gl
|
|
|
|
|
.B or
|
|
|
|
|
.B -lg
|
|
|
|
|
for \(lqless than or greater than\(rq;
|
2024-06-02 18:47:14 -06:00
|
|
|
|
this is elegant but unintuitive.
|
|
|
|
|
.\"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH RATIONALE
|
2024-06-03 23:07:19 -06:00
|
|
|
|
|
2023-12-24 17:13:17 -07:00
|
|
|
|
The traditional tool for integer comparisons in POSIX and other Unix shells has
|
2024-06-02 18:47:14 -06:00
|
|
|
|
been
|
|
|
|
|
.BR test (1).
|
|
|
|
|
This tool also handles string comparisons and file scrutiny. These parts of its
|
|
|
|
|
functionality have been broken out into multiple utilities.
|
|
|
|
|
|
|
|
|
|
This program\(cqs functionality may be performed on a POSIX-compliant system
|
|
|
|
|
with
|
|
|
|
|
.BR test (1p).
|
|
|
|
|
.\"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH AUTHOR
|
2024-06-03 23:07:19 -06:00
|
|
|
|
|
2024-06-02 18:47:14 -06:00
|
|
|
|
Written by DTB
|
|
|
|
|
.MT trinity@trinity.moe
|
|
|
|
|
.ME .
|
|
|
|
|
.\"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH COPYRIGHT
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.\"
|
|
|
|
|
Copyright \(co 2023 DTB. License AGPLv3+: GNU AGPL version 3 or later
|
2023-12-24 17:13:17 -07:00
|
|
|
|
<https://gnu.org/licenses/gpl.html>.
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.\"
|
2023-12-24 17:13:17 -07:00
|
|
|
|
.SH SEE ALSO
|
2024-06-02 18:47:14 -06:00
|
|
|
|
.BR scrut (1),
|
|
|
|
|
.BR strcmp (1),
|
|
|
|
|
.BR str (1),
|
|
|
|
|
.BR test (1p)
|