Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
9390811b24
|
|||
|
b7fe7294c6
|
|||
|
6334f41e0b
|
|||
| f521c309ab | |||
|
4b3333d8d3
|
|||
|
578d947561
|
|||
|
2e91338101
|
|||
|
72f57ba08b
|
|||
|
35f49a699f
|
|||
|
125b4c8930
|
|||
|
f553cff096
|
|||
|
d201f9228c
|
|||
|
43d9193252
|
|||
|
22345245f1
|
|||
|
99783281e1
|
|||
|
fe5c020590
|
|||
|
ba55c4c8e7
|
|||
|
003f5aeb1f
|
|||
|
327c71c8ae
|
|||
|
b06c1d5488
|
|||
|
82f6c46b64
|
|||
|
81c657ec3e
|
|||
|
82a941eee3
|
|||
|
e674027b3e
|
22
Makefile
22
Makefile
@@ -8,11 +8,10 @@
|
|||||||
# permitted in any medium without royalty provided the copyright notice and this
|
# permitted in any medium without royalty provided the copyright notice and this
|
||||||
# notice are preserved. This file is offered as-is, without any warranty.
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
.POSIX:
|
# The octal escape \043 is utilized twice in this file as make(1p) will
|
||||||
|
# interpret a hash in a rule as an inline comment.
|
||||||
|
|
||||||
# if using BSD make(1), remove these pragmas because they break it
|
.POSIX:
|
||||||
.PRAGMA: posix_202x # future POSIX standard support à la pdpmake(1)
|
|
||||||
.PRAGMA: command_comment # breaks without this?
|
|
||||||
|
|
||||||
DESTDIR ?= dist
|
DESTDIR ?= dist
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
@@ -30,11 +29,11 @@ RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \
|
|||||||
CFLAGS += -I$(SYSEXITS)
|
CFLAGS += -I$(SYSEXITS)
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: dj false fop hru intcmp mm npc rpn scrut str strcmp swab true
|
all: dj eep false fop hru intcmp mm npc rpn scrut str strcmp swab true
|
||||||
|
|
||||||
|
# keep build/include until bindgen(1) has stdin support
|
||||||
|
# https://github.com/rust-lang/rust-bindgen/issues/2703
|
||||||
build:
|
build:
|
||||||
# keep build/include until bindgen(1) has stdin support
|
|
||||||
# https://github.com/rust-lang/rust-bindgen/issues/2703
|
|
||||||
mkdir -p build/bin build/include build/lib build/o build/test
|
mkdir -p build/bin build/include build/lib build/o build/test
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
@@ -67,9 +66,9 @@ build/o/libstrerror.rlib: build src/strerror.rs
|
|||||||
$(RUSTC) $(RUSTFLAGS) --crate-type=lib -o $@ \
|
$(RUSTC) $(RUSTFLAGS) --crate-type=lib -o $@ \
|
||||||
src/strerror.rs
|
src/strerror.rs
|
||||||
|
|
||||||
|
# bandage solution until bindgen(1) gets stdin support
|
||||||
build/o/libsysexits.rlib: build $(SYSEXITS)sysexits.h
|
build/o/libsysexits.rlib: build $(SYSEXITS)sysexits.h
|
||||||
# bandage solution until bindgen(1) gets stdin support
|
printf '\043define EXIT_FAILURE 1\n' | cat - $(SYSEXITS)sysexits.h \
|
||||||
printf '#define EXIT_FAILURE 1\n' | cat - $(SYSEXITS)sysexits.h \
|
|
||||||
> build/include/sysexits.h
|
> build/include/sysexits.h
|
||||||
bindgen --default-macro-constant-type signed --use-core --formatter=none \
|
bindgen --default-macro-constant-type signed --use-core --formatter=none \
|
||||||
build/include/sysexits.h | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ -
|
build/include/sysexits.h | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ -
|
||||||
@@ -119,6 +118,11 @@ scrut: build/bin/scrut
|
|||||||
build/bin/scrut: src/scrut.c build
|
build/bin/scrut: src/scrut.c build
|
||||||
$(CC) $(CFLAGS) -o $@ src/scrut.c
|
$(CC) $(CFLAGS) -o $@ src/scrut.c
|
||||||
|
|
||||||
|
.PHONY: eep
|
||||||
|
eep: build/bin/eep
|
||||||
|
build/bin/eep: src/eep.rs build rustlibs
|
||||||
|
$(RUSTC) $(RUSTFLAGS) -o $@ src/eep.rs
|
||||||
|
|
||||||
.PHONY: str
|
.PHONY: str
|
||||||
str: build/bin/str
|
str: build/bin/str
|
||||||
build/bin/str: src/str.c build
|
build/bin/str: src/str.c build
|
||||||
|
|||||||
10
README
10
README
@@ -1,9 +1,11 @@
|
|||||||
“Seek not to walk the path of the masters; seek what they sought.”
|
“Seek not to walk the path of the masters; seek what they sought.”
|
||||||
– Matsuo Basho
|
– Matsuo Basho
|
||||||
|
|
||||||
The Bonsai core utilities are the result of the careful examination of the
|
The Bonsai core utilities are a replacement for standard POSIX utilities which
|
||||||
current state of POSIX and Unix utilies. The Unix Philosophy, “do one thing and
|
aim to fill its niche while expanding on their capabilities. These new tools are
|
||||||
do it well” is its core but these tools do not cling to the names of the past.
|
the result of the careful examination of the current state of POSIX and Unix
|
||||||
|
utilies. The Unix Philosophy of “do one thing and do it well” are their core but
|
||||||
|
they avoid clinging to the past.
|
||||||
|
|
||||||
The era of the original Unix tools has been long and fruitful, but they have
|
The era of the original Unix tools has been long and fruitful, but they have
|
||||||
their flaws. The new, non-POSIX era of this project started with frustration
|
their flaws. The new, non-POSIX era of this project started with frustration
|
||||||
@@ -38,7 +40,7 @@ To test the utilities:
|
|||||||
|
|
||||||
$ make test
|
$ make test
|
||||||
|
|
||||||
To remove all untracked files:
|
To remove all build and distributable files:
|
||||||
|
|
||||||
$ make clean
|
$ make clean
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH DJ 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH DJ 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
dj \(en disk jockey
|
dj \(en disk jockey
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
43
docs/eep.1
Normal file
43
docs/eep.1
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
.\" 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 EEP 1
|
||||||
|
.SH NAME
|
||||||
|
eep \(en wait a moment
|
||||||
|
.\"
|
||||||
|
.SH SYNOPSIS
|
||||||
|
|
||||||
|
eep
|
||||||
|
.RB [ seconds ]
|
||||||
|
.\"
|
||||||
|
.SH DESCRIPTION
|
||||||
|
|
||||||
|
Wait a specified number of seconds before exiting.
|
||||||
|
.\"
|
||||||
|
.SH DIAGNOSTICS
|
||||||
|
|
||||||
|
If the specified time fails to elapse or in the case of incorrect invocation,
|
||||||
|
the program will exit unsuccessfully. In the latter scenario, a debug message
|
||||||
|
will be printed.
|
||||||
|
.\"
|
||||||
|
.SH CAVEATS
|
||||||
|
|
||||||
|
User may still be tired after invocation.
|
||||||
|
.\"
|
||||||
|
.SH AUTHOR
|
||||||
|
|
||||||
|
Written by DTB
|
||||||
|
.MT trinity@trinity.moe
|
||||||
|
.ME .
|
||||||
|
.\"
|
||||||
|
.SH COPYRIGHT
|
||||||
|
|
||||||
|
Copyright \(co 2024 DTB. License AGPLv3+: GNU AGPL version 3 or later
|
||||||
|
<https://gnu.org/licenses/gpl.html>.
|
||||||
|
.\"
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR sleep (3p)
|
||||||
|
.BR sleep (1p)
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH FALSE 1 2024-06-06 "Bonsai Core Utilites 0.13.9"
|
.TH FALSE 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
false \(en do nothing, unsuccessfully
|
false \(en do nothing, unsuccessfully
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH FOP 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH FOP 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fop \(en field operator
|
fop \(en field operator
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH HRU 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH HRU 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
hru \(en human readable units
|
hru \(en human readable units
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH INTCMP 1 2024-06-06 "Bonsai Core Utilites 0.13.9"
|
.TH INTCMP 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
intcmp \(en compare integers
|
intcmp \(en compare integers
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH MM 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH MM 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
mm \(en middleman
|
mm \(en middleman
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH NPC 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH NPC 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
npc \(en show non-printing characters
|
npc \(en show non-printing characters
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH RPN 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH RPN 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
rpn \(en reverse polish notation evaluation
|
rpn \(en reverse polish notation evaluation
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH SCRUT 1 2024-06-06 "Bonsai Core Utilites 0.13.9"
|
.TH SCRUT 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
scrut \(en scrutinize file properties
|
scrut \(en scrutinize file properties
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH STR 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH STR 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
str \(en test string arguments
|
str \(en test string arguments
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH STRCMP 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH STRCMP 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
strcmp \(en compare strings
|
strcmp \(en compare strings
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH SWAB 1 2024-06-17 "Bonsai Core Utilites 0.13.9"
|
.TH SWAB 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
swab \(en swap bytes
|
swab \(en swap bytes
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
.\" 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/>.
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
.\"
|
.\"
|
||||||
.TH TRUE 1 2024-06-06 "Bonsai Core Utilites 0.13.9"
|
.TH TRUE 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
true \(en do nothing, successfully
|
true \(en do nothing, successfully
|
||||||
.\"
|
.\"
|
||||||
|
|||||||
47
src/eep.rs
Normal file
47
src/eep.rs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024 DTB <trinity@trinity.moe>
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU Affero General Public License as published by the Free
|
||||||
|
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
env::args,
|
||||||
|
process::ExitCode,
|
||||||
|
thread::sleep,
|
||||||
|
time::Duration
|
||||||
|
};
|
||||||
|
|
||||||
|
extern crate sysexits;
|
||||||
|
use sysexits::EX_USAGE;
|
||||||
|
|
||||||
|
fn usage(s: &str) -> ExitCode {
|
||||||
|
eprintln!("Usage: {} [seconds]", s);
|
||||||
|
ExitCode::from(EX_USAGE as u8)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> ExitCode {
|
||||||
|
let argv = args().collect::<Vec<String>>();
|
||||||
|
|
||||||
|
if argv.len() == 2 {
|
||||||
|
if let Ok(s) = argv[1].parse::<u64>() {
|
||||||
|
sleep(Duration::from_secs(s)); /* from_secs needs u64 */
|
||||||
|
ExitCode::SUCCESS
|
||||||
|
} else {
|
||||||
|
usage(&argv[0])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usage(&argv[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE };
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
let mut d = 0x1E.to_string();
|
let mut d = '\u{1E}'.to_string();
|
||||||
let mut arg_parser = Parser::new(&argv, "d:");
|
let mut arg_parser = Parser::new(&argv, "d:");
|
||||||
|
|
||||||
while let Some(opt) = arg_parser.next() {
|
while let Some(opt) = arg_parser.next() {
|
||||||
|
|||||||
Reference in New Issue
Block a user