Compare commits

...

114 Commits

Author SHA1 Message Date
90de81b5bd
Merge branch 'quick-fixes' into trunk 2025-11-05 13:35:15 -07:00
1bd190ae99
mm.1: fixed attributions 2025-11-02 12:20:17 -07:00
791f44aa1e
dj.1, mm(1): updates dates for copyright and modification 2025-11-02 01:14:17 -06:00
feac3bf4f8
mm(1): fixes bug with -a; mm.1, tests/mm.mk: changes to test regression in -a and -t 2025-11-02 01:12:27 -06:00
544b544d84
mm.1: removed description of removed behavior 2025-11-02 00:30:27 -06:00
1750329c51
mm.1: removed erroneous copyrighy section 2025-10-27 01:53:50 -06:00
be6bd5386d
docs: POSIX → \*(Px 2025-10-26 20:10:24 -06:00
3b44ddeedd
scrut(1): remove erroneous utility from tree 2025-10-26 17:07:52 -06:00
8d8df711d9
all: formatting; mm(1): fixes speed, simplicity; docs/dj.1: grammar, typos, etc. 2025-10-26 16:58:13 -06:00
ac0f9e4019
README: add CONTRIBUTING mention 2025-04-03 16:46:50 -06:00
247e469f82
CONTRIBUTING, STYLE: merge into CONTRIBUTING 2025-04-03 16:45:22 -06:00
8eece4cf84
Makefile: removes deprecated variable 2025-03-28 19:38:51 -06:00
0e9127d417
tests: removed POSIX testing (fixes #163) 2025-02-24 23:28:52 -07:00
e6f747d635
Merge branch 'npc-broken-tests' 2025-02-24 23:19:47 -07:00
9b699d7298
Makefile, tests/bonsai/scrut.mk: cleanup 2025-02-24 23:17:10 -07:00
941f931f8b
Merge branch libfileis 2025-02-24 23:13:13 -07:00
f0eac562b3
tests: bonsai/npc.mk: fixed copyright header 2025-02-24 23:08:28 -07:00
138044e52f
Merge branch 'optimizations' 2025-02-24 23:04:10 -07:00
bd8bc0094d
rpn(1): fixes erroneous OpenBSD-gated import 2025-02-24 23:03:31 -07:00
99a99cdcb5
Merge branch 'style-c' 2025-02-24 22:59:50 -07:00
008c0624f6
tests: bonsai/npc.mk: removed test that is broken with GNU and BusyBox 2025-02-24 22:57:42 -07:00
982c67df13
intcmp(1), swab(1): consistent type annotations 2024-10-01 22:08:56 -06:00
07a2f1efc2
Merge branch 'man-fixes' 2024-09-11 15:42:58 -06:00
c4cd2563f9
scrut(1): fixes failing write test 2024-09-11 03:26:00 -06:00
8bdb72ece8
false(1): fixes pledge(2) invocation 2024-09-11 03:19:56 -06:00
ba73f50527
true(1): removes NULL from commented imports 2024-09-11 03:19:23 -06:00
579bb98874
true(1): fixes pledge(2) invocation 2024-09-11 03:18:01 -06:00
8f1e570b50
strcmp(1): fixes pledge(2) invocation 2024-09-11 03:15:58 -06:00
a43daf2cf2
str(1): fixes pledge(2) invocation 2024-09-11 03:15:13 -06:00
f25a499ca0
scrut(1): fixes pledge(2) invocation 2024-09-11 03:14:36 -06:00
e0b5467fb6
npc(1): fixes pledge invocation 2024-09-11 03:13:38 -06:00
7498b283ce
mm(1): updates to use new unveil api 2024-09-11 02:32:32 -06:00
0b3ed37c38
libopenbsd.rs(3): makes using statically-allocated arrays possible 2024-09-11 02:32:03 -06:00
800a097903
swab(1): uses default for promises 2024-09-10 17:14:02 -06:00
1ccdc65d30
rpn(1): uses default for promises 2024-09-10 17:13:20 -06:00
df0a236f81
mm(1): uses default for Promises 2024-09-10 17:12:14 -06:00
e385d873ec
intcmp(1): uses default value for Promises 2024-09-10 17:11:22 -06:00
73a75a32df
hru(1): uses default Promises value for child processes 2024-09-10 17:10:26 -06:00
b8e5901d97
libopenbsd.rs(3): adds default value for Promises 2024-09-10 17:09:46 -06:00
f4bd4de2e4
fileis(1): various changes to make the code more efficient and idiomatic 2024-09-10 02:42:55 -06:00
f66fdef9c3
STYLE: avoid unbounded loops 2024-09-10 02:05:01 -06:00
b56a66f980
STYLE: fixes default case in example 2024-09-10 01:59:59 -06:00
f6559b464a
STYLE: fix minor issues 2024-09-07 12:51:18 -06:00
accec33301
Makefile: fixes abuse of relative paths 2024-09-05 17:12:39 -06:00
444e682f02
Merge branch 'rdme' 2024-09-05 17:02:31 -06:00
790b12fb40
STYLE: changes numbering scheme to transcend headers, fixes minor errors 2024-09-05 15:55:32 -06:00
fde682a10e
Makefile: fixes manpage installation location 2024-09-05 12:57:55 -06:00
4cb5ea78d7
STYLE: improves clarity, focus, distribution of items, adds more gripes, includes usage text style 2024-09-05 12:44:14 -06:00
62ce288524
rpn(1): makes rounding more efficient 2024-09-04 22:12:44 -06:00
DTB
87c9e29932
tests: bonsai/peek.mk 2024-09-01 08:51:33 -06:00
DTB
1037e32e6e
peek(1): fix erroring on stdin/stdout redirection 2024-09-01 08:50:13 -06:00
DTB
5c70852890
peek.1: replace parens with square brackets 2024-09-01 08:50:12 -06:00
DTB
8ec18ccf75
peek(1): use stdbool.h 2024-09-01 08:50:12 -06:00
DTB
3bfdc62035
peek(1): better error on piping 2024-09-01 08:50:12 -06:00
DTB
7d174c1f7c
peek(1): warn on pledge(2) or unveil(2) errors 2024-09-01 08:50:12 -06:00
DTB
3f41110617
peek(1): pledge(2) and unveil(2) on OpenBSD 2024-09-01 08:50:11 -06:00
DTB
7a69e1d516
peek.1: correct references to use the 1p section, add reference to stty(1p) 2024-09-01 08:50:11 -06:00
DTB
64e943f64a
peek(1): fix ioerr typos 2024-09-01 08:50:11 -06:00
DTB
16dcd4da37
peek(1): more style fixes 2024-09-01 08:50:11 -06:00
DTB
d892fa1cac
peek(1): update style 2024-09-01 08:50:11 -06:00
DTB
3862a95151
peek.1: s/inputted/input/ 2024-09-01 08:48:26 -06:00
DTB
264ae2e82c
peek.1: fix version string 2024-09-01 08:48:26 -06:00
DTB
1634761593
peek.1: fix wording on -i 2024-09-01 08:48:26 -06:00
DTB
0b40360e7e
Makefile: all: add peek 2024-09-01 08:48:26 -06:00
590d98d7f7
peek.1: updates to be more consistent with current documentation 2024-09-01 08:48:26 -06:00
DTB
07aa9a9abc
peek(1): remove unused variables, clean up some typos 2024-09-01 08:48:25 -06:00
DTB
fce49bed85
peek(1): correct grammar 2024-09-01 08:46:56 -06:00
DTB
62b38a6765
peek(1): strip down to bare essentials, rewrite man page to match 2024-09-01 08:46:56 -06:00
DTB
23521bade5
peek(1): remove -p 2024-09-01 08:46:56 -06:00
DTB
3b774cab27
Import peek(1) from trinity/src 2024-09-01 08:46:52 -06:00
e889159619
CONTRIBUTING: made better 2024-08-30 21:22:53 -06:00
731e62ee7e
rpn(1): made evaluation function more readable 2024-08-28 18:24:49 -06:00
f50bfeea92
fop(1): fixes panic on no arguments 2024-08-28 18:05:56 -06:00
8d00fa0afd
fop(1): minor formatting change 2024-08-28 00:46:32 -06:00
9f520df82b
strcmp(1): adds null unveil 2024-08-28 00:31:02 -06:00
41982c2f73
str(1): adds null unveil 2024-08-28 00:30:45 -06:00
6166a3ca36
npc(1): adds null unveil 2024-08-28 00:26:26 -06:00
efedcd3ae4
true(1), false(1): adds null unveils 2024-08-28 00:24:35 -06:00
8fd5bdf5a6
swab(1): adds null unveil 2024-08-28 00:15:15 -06:00
b946469da5
rpn(1): adds null unveil 2024-08-28 00:13:21 -06:00
06384c72fb
intcmp(1): adds null unveil 2024-08-28 00:09:40 -06:00
9aeadd8f8f
hru(1): adds null unveil 2024-08-27 23:57:12 -06:00
5b666d6858
fop(1): adds null unveil 2024-08-27 23:54:39 -06:00
b875aa1058
rpn(1): more improvements 2024-08-24 19:00:01 -06:00
cc53dab035
rpn(1): handles errors when writing to stdout 2024-08-24 18:18:27 -06:00
232629f4d3
hru(1): makes more efficient 2024-08-24 17:55:00 -06:00
ff4ff825bd
swab(1): changes disparate error handling functions to one function 2024-08-24 17:26:26 -06:00
5eb71e90a3
tests/bonsai: rpn.mk: tests the standard input 2024-08-24 17:22:57 -06:00
a0138be79e
rpn(1): refactor to make code more efficient, readable, and maintainable 2024-08-24 17:22:02 -06:00
150fa22f35
fop(1): changes casts to calls to .into() 2024-08-24 15:57:55 -06:00
f104598164
mm(1): updates error-handling functions and uncovers issue with error reporting 2024-08-24 15:53:58 -06:00
722679247a
hru(1): uses new sysexits 2024-08-23 14:31:02 -06:00
4db4160019
swab(1): uses new sysexits 2024-08-23 14:23:11 -06:00
928dce0234
fop(1): uses new sysexits 2024-08-23 14:22:11 -06:00
1fffd3df52
Makefile: sets bindgen to output exit codes as u8 2024-08-23 14:21:43 -06:00
a14b8fb9d7
fop(1): adds functions for error handling 2024-08-23 13:35:30 -06:00
dd39aeff02
mm(1): adds ioerr(), usage(), and oser() functions 2024-08-22 00:22:05 -06:00
fbacfecce8
Merge branch 'linux-fix' (closes #158) 2024-08-21 22:43:29 -06:00
DTB
579ff65b67
tests: bonsai/npc.mk: drop redundant tab removal 2024-08-21 21:59:22 -06:00
DTB
334433536b
tests: bonsai/npc.mk: fix harrowing ordeal of a Linux error 2024-08-21 21:57:10 -06:00
71d4d6ba05
tests: bonsai/dj.mk, bonsai/rpn.mk: fixes testing on linux 2024-08-17 01:57:16 -06:00
821f5d09e9
fop(1), hru(1), intcmp(1), mm(1), rpn(1), swab(1): fixes conditional compilation 2024-08-17 01:51:25 -06:00
d2f8fb8106
README: improvements, community links 2024-08-12 17:53:43 -06:00
DTB
8646d5c4ee
STYLE: make rules more granular and consistent, add examples 2024-08-08 02:31:54 -06:00
DTB
6d7173e438
libfileis(3): finish removal 2024-07-18 20:50:12 -06:00
DTB
958f08bd9e
fileis.1: rename from scrut.1 2024-07-18 20:45:14 -06:00
DTB
02b5edae05
fileis(1): feature parity with C scrut(1) 2024-07-18 20:43:39 -06:00
DTB
0819eeb75d
fileis(1): scrap libfileis(3), work on rewriting scrut(1) in Rust 2024-07-18 19:11:22 -06:00
DTB
cd875df547
README: attempt to clarify intent 2024-07-18 09:32:58 -06:00
DTB
0f12dcc552
scrut(1): fix ugly opt parsing 2024-07-15 14:28:00 -06:00
DTB
b9c4b49603
scrut(1): use libfileis 2024-07-15 14:13:53 -06:00
DTB
2c4349872c
scrut(1): banish gotos 2024-07-15 13:55:01 -06:00
DTB
59fa3ed3d2
scrut(1): get rid of -h 2024-07-15 13:47:55 -06:00
DTB
71655a8559
libfileis(3): a library for scrutinizing files 2024-07-15 13:47:04 -06:00
61 changed files with 1877 additions and 974 deletions

12
CONDUCT
View File

@ -36,9 +36,9 @@ issues, pull requests, and other endeavors in order to keep yourself and others
from being overwhelmed with responsibility, either from your zeal or your from being overwhelmed with responsibility, either from your zeal or your
negligence. negligence.
If you notice an issue, open an issue as soon as you can. If you see a neglected If you notice an issue, open an issue as soon as you can. If you see a
branch, open a pull request or comment on an existing one, if applicable. Be neglected branch, open a pull request or comment on an existing one, if
diligent in your commitment to making this project work. applicable. Be diligent in your commitment to making this project work.
6. Patience (Khanti) 6. Patience (Khanti)
@ -81,3 +81,9 @@ more insight.
[0] <https://www.dhammatalks.org/books/#/books/TenPerfections/Section0001.html> [0] <https://www.dhammatalks.org/books/#/books/TenPerfections/Section0001.html>
[1] <https://www.fsf.org/news/publication-of-the-fsf-funded-white-papers-on-questions-around-copilot> [1] <https://www.fsf.org/news/publication-of-the-fsf-funded-white-papers-on-questions-around-copilot>
--
Copyright © 20242025 Emma Tebibyte <emma@tebibyte.media>
This work is licensed under CC BY-SA 4.0. To view a copy of this license, visit
<http://creativecommons.org/licenses/by-sa/4.0/>.

View File

@ -1,26 +1,29 @@
Make sure to read our code of conduct in the CONDUCT file. Make sure to read our code of conduct in the CONDUCT file.
When contributing a pull request to the main branch, please sign your commits
with a PGP key and add your name and the year to the bottom of the list of Copyright Information
copyright holders for the file. For example, an existing copyright header might =====================
read:
When editing a file, create a copyright statement correlated to your
identity so that it is easier to keep track of who has touched what file.
Pseudonymous contributions are welcome (and encouraged). Place new copyright
information below existing copyright information. If there is an existing
copyright statement:
* Copyright (c) 20222023 Emma Tebibyte <emma@tebibyte.media> * Copyright (c) 20222023 Emma Tebibyte <emma@tebibyte.media>
You would add your name below it like this: you would add your name below it like this:
* Copyright (c) 20222023 Emma Tebibyte <emma@tebibyte.media> * Copyright (c) 20222023 Emma Tebibyte <emma@tebibyte.media>
* Copyright (c) 20XX Your Name <your e-mail address or website> * Copyright (c) 20XX Your Name <your e-mail address or website>
We accept contributions from people using aliases.
Only list years in which you modified the source file. For example: Only list years in which you modified the source file. For example:
* Copyright (c) 20202021, 2023 Your Name <your-address@example.com> * Copyright (c) 20202021, 2023 Your Name <your-address@example.com>
This header shows that “Your Name” worked on this source file in 2020, 2021, and This header shows that “Your Name” worked on this source file in 2020, 2021, and
2023. Please use the en dash (“–”) to separate the years in the copyright 2023. Please use the en dash (“–”, U+2013) to separate consecutive years in the
notice. copyright notice.
If you are contributing a new file, please prepend the following license header If you are contributing a new file, please prepend the following license header
text to it, replacing the proper text on the copyright line: text to it, replacing the proper text on the copyright line:
@ -92,20 +95,263 @@ notice:
* USE OR OTHER DEALINGS IN THE SOFTWARE. * USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
Make sure lines never exceed 80 columns in width when using four-character
indentation steps. This helps contributors with smaller screens, those using
side-by-side editor windows or panes, and those who have no text wrapping in
their editor or terminal.
For usage text and help messages, do not implement a -h option. Instead, print Style
usage information when any erroneous option is specified. Follow the NetBSD =====
style guide for the usage texts output format [0].
“Everyone knows that debugging is twice as hard as writing a program in the
first place. So if youre as clever as you can be when you write it, how
will you ever debug it?”
Brian Kernighan, The Elements of Programming Style
The following guidelines are conducive to clear and readable code that is
consistent with the style of the rest of the Bonsai Computer System.
Use:
0. A single line for control flow statements short enough to be easily
understood at a glance:
if !(argc < 0) { usage(program_name); }
This applies to C switch statements and cases and Rust match statements, as
well:
switch (value) { /* aligning stuff to make it easier to read is fine */
case possibility: variable = foo; break;
default: variable = NULL; break;
}
1. Switch cases in C and match arms in Rust should start another level of
indentation:
switch (value) {
case possibility:
statement;
break;
default:
statement;
break;
}
match result {
Ok(n) => variable = n,
Err(e) => error = e,
}
2. Braces in control flow where their inclusion is left optional in C:
if (condition) { statement; }
3. Empty lines between different kinds of statements:
int t;
assert(io->bufuse > 0);
assert(io->bufuse <= io->bs);
if ((t = write(io->fd, io->buf, io->bufuse)) < 0) {
io->error = errno;
t = 0;
} else if (t > 0) {
memmove(io->buf, &(io->buf)[t], (io->bufuse -= t));
}
io->bytes += t;
io->prec += (t > 0 && io->bufuse > 0);
io->rec += (t > 0 && io->bufuse == 0);
return io;
4. Compiler options that yield the most useful warnings, such as -Wpedantic in
a lot of C compilers. Fix the warnings, too [0].
5. One more level of indentation and one argument per line when a function
call or statement header is too long to fit on one line:
let usage = format!(
"Usage: {} [-d delimiter] index command [args...]",
argv[0],
);
6. One more level of indentation than the keyword that initiated a multi-line
block.
if (condition) {
statement;
statement;
}
7. The return value of all non-void functions, or explicitly ignore them (like
casting to void in C) [0]:
if ((a = malloc(sizeof char)) == NULL) { /* handle this error */
(void)fprintf(stderr, "oh noes!"); /* explicitly ignore this one */
return EX_OSERR; /* ...because the program is exiting anyway */
}
8. The smallest possible scope for data [0].
9. Comments noting all the symbols and macros used from a C header file, next
to its include macro:
#include <unistd.h> /* close(2), getopt(3), lseek(2), read(2), write(2),
(space-aligned) * optarg, optind, STDIN_FILENO, STDOUT_FILENO */
10. Spaces in control flow statements, after the keyword and before the
opening brace:
for (i = 2; i < argc; ++i) {
11. In Rust, a trailing comma on all arguments or fields that are on their own
lines:
return Err(EvaluationError {
message: format!("{}: Invalid token", i),
code: EX_DATAERR,
})
12. In Rust, place extern statements after use statements that include standard
library crates. Group like statements:
use std::fs::Path;
extern crate strerror;
extern crate sysexits;
use strerror::StrError;
use sysexits::{ EX_OSERR, EX_USAGE };
13. If text is on the same line as a brace, spaces after an opening brace and
before a closing one:
use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE };
14. Alphabetic sorting, where applicable:
use std::io::{ BufWriter, Read, Write, stderr, stdin, stdout }
15. In Rust, use the to_owned() method on string types (str, OsStr, CStr, etc.)
and the to_string() method on other types.
Avoid:
16. Unbounded loops [0].
17. Function pointers [0].
18. Heap memory allocation [0].
19. Using too much nested logic (within reason).
20. Too many levels of dereferences [0]:
/* do not do this */
for (size_t i = 0; i < sizeof a / sizeof *a; ++i) {
if (a[i].id == MATCH) { a[i].val = 0; }
}
/* do this */
for (struct MadeUp *s = &a[0]; *s != NULL; s = &s[1]) {
if (s->id == MATCH) { s->val = 0; }
}
21. Using C preprocessor macros; the fewer, the better [0].
22. The exit(3p) and std::process::exit() functions; returning from the main
function skips a system call.
Do not use:
23. More than the length of one printed page for a function [0].
24. Recursion, as its complex and can unexpectedly overflow the stack [0].
25. Any functionality not in the POSIX C specification and language features not
in C99.
26. Do-while loops, as theyre unique to C and confusing for casual programmers.
27. Labels and goto statements; use sensible flow control [0].
28. Pointer arithmetic, as it tends to be confusing and unnecessary; use
index-reference patterns like &p[1] instead of p + 1. &p[n] is the address at
p + sizeof p * n, not p + n, like pointer arithmetic suggests.
29. C struct bitfields in unions, to access certain bits of bigger data types,
as its poorly defined in the C standards; use bit arithmetic.
30. C trigraphs.
31. Inclusions in C header files, to prevent multiple file inclusions.
32. C preprocessor variables to prevent multiple inclusions of the same file,
such as:
#ifdef _FILE
#define _FILE
/* file body */
#endif /* ifdef _FILE */
Instead, take the time to ensure other files arent including any files twice.
33. The gets(3p) function from <stdio.h>, as its impossible to prevent buffer
overflows when it's used; use fgets(3p) from <stdio.h>.
34. The scanf(3p) function from <stdio.h> [1].
35. Any functionality not described in the latest POSIX make(1) specification.
36. Macros which panic on failure in Rust (such as the print!() and println!()
macros). Use a function and handle any errors. However, do use the eprintln!()
macro for error messages. Handling an error for writing an error message is
redundant.
37. A -h option for help text. Instead, print usage information when any
erroneous option is specified. See the Usage Text section below.
38. Lines which exceed 80 columns in width when using four-column indentation
steps. This helps contributors with smaller screens, those using side-by-side
editor windows or panes, and those who have no text wrapping in their editor or
terminal.
Usage Text
==========
This section is adapted from the NetBSD style guide [2].
When programs are invoked incorrectly and in the synopsis of manual pages, uasge
text should be provided to the user. The following is the format used by this
project for this purpose:
All optional arguments are to be placed in square brackets (U+005B, U+005D).
Mutually exclusive arguments can be separated by a vertical line (U+007C).
Groups of arguments should be specified in alphabetical order in most cases. The
order of arguments and an example of these rules follows:
0. Options with no option arguments.
1. Options with option arguments. Arguments should be specified inside the same
square brackets as the options.
3. Non-option arguments.
"usage: f [-aDde] [-b b_arg] [-m m_arg] req1 req2 [opt1 [opt2]]\n"
"usage: f [-a | -b] [-c [-de] [-n number]]\n"
Committing
==========
When contributing to Bonsai, please sign your commit with a PGP key and create
the commit with an identity which can be easily contacted.
If committing a new utility, please include tests and documentation (see If committing a new utility, please include tests and documentation (see
tests/ and docs/) for the new tool. tests/ and docs/) for the new tool.
If committing a new source file, format the commit message following these
guidelines: Format commit messages following these guidelines:
$ git commit -m 'tool(1): add feature x' $ git commit -m 'tool(1): add feature x'