16 Commits

Author SHA1 Message Date
DTB
9390811b24 Makefile: eep: update recipe 2024-08-21 22:03:07 -06:00
DTB
b7fe7294c6 eep(1): comment why u64 number 2024-07-15 15:45:50 -06:00
DTB
6334f41e0b Merge branch 'main' into sleep 2024-06-26 15:37:46 -06:00
f521c309ab eep.1: Apply formatting changes 2024-06-26 09:10:15 -06:00
43d9193252 eep.1: can’t believe i missed this 2024-06-08 23:51:57 -06:00
22345245f1 eep.1: renames sleep in the text 2024-06-08 23:49:59 -06:00
99783281e1 eep.1: rename from sleep.1 2024-06-08 23:47:48 -06:00
fe5c020590 sleep(1): rename to eep(1) 2024-05-29 19:37:18 -06:00
DTB
ba55c4c8e7 sleep.1: add copyright header 2024-05-03 21:32:10 -06:00
DTB
003f5aeb1f Makefile: add sleep to the all recipe 2024-05-03 21:30:39 -06:00
DTB
327c71c8ae sleep.1: import from trinity/src 2024-05-03 21:29:49 -06:00
DTB
b06c1d5488 sleep(1): reduce dependence on sysexits 2024-05-03 21:22:38 -06:00
DTB
82f6c46b64 Makefile: update sleep recipe 2024-05-03 21:22:07 -06:00
DTB
81c657ec3e Merge branch 'main' into sleep 2024-05-03 21:19:19 -06:00
DTB
82a941eee3 sleep(1): initial implementation 2024-03-21 20:41:05 -06:00
DTB
e674027b3e Makefile: add sleep(1) 2024-03-21 20:40:19 -06:00
17 changed files with 123 additions and 34 deletions

View File

@@ -29,12 +29,12 @@ RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \
CFLAGS += -I$(SYSEXITS)
.PHONY: all
all: docs 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:
mkdir -p build/bin build/docs build/include build/lib build/o build/test
mkdir -p build/bin build/include build/lib build/o build/test
.PHONY: clean
clean:
@@ -43,7 +43,7 @@ clean:
dist: all
mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
cp build/bin/* $(DESTDIR)/$(PREFIX)/bin
cp build/docs/*.1 $(DESTDIR)/$(PREFIX)/$(MANDIR)/man1
cp docs/*.1 $(DESTDIR)/$(PREFIX)/$(MANDIR)/man1
.PHONY: install
install: dist
@@ -54,13 +54,6 @@ test: build
tests/posix-compat.sh
$(RUSTC) --test src/getopt-rs/lib.rs -o build/test/getopt
.PHONY: docs
docs: docs/ build
for file in docs/*; do original="$$(sed -n '/^\.TH/p' <"$$file")"; \
title="$$(printf '%s\n' "$$original" | sed \
"s/X\.X\.X/$$(git describe --tags --long | cut -d'-' -f1)/g")"; \
sed "s/$$original/$$title/g" <"$$file" >"build/$$file"; done
.PHONY: rustlibs
rustlibs: build/o/libsysexits.rlib build/o/libgetopt.rlib \
build/o/libstrerror.rlib
@@ -125,6 +118,11 @@ scrut: build/bin/scrut
build/bin/scrut: src/scrut.c build
$(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
str: build/bin/str
build/bin/str: src/str.c build

23
README
View File

@@ -1,27 +1,28 @@
“Seek not to walk the path of the masters; seek what they sought.”
Matsuo Basho
The Bonsai harakit utilities are a replacement for standard POSIX utilities
which aim to fill its niche while expanding on their capabilities. These new
tools are 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 Bonsai core utilities are a replacement for standard POSIX utilities which
aim to fill its niche while expanding on their capabilities. These new tools are
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
their flaws. This project originated from frustrations with the way certain
tools work and how other projects that extend POSIX dont make anything better.
their flaws. The new, non-POSIX era of this project started with frustration
with the way certain tools work and how other projects that extend POSIX dont
make anything better.
This project will not follow in the footsteps of GNU; extensions of POSIX will
not be found here. GNU extensions are a gateway to the misuse of the shell. The
harakit utilities will intentionally discourage use of the shell for purposes
beyond its scope.
Bonsai core utilities will intentionally discourage use of the shell for
purposes beyond its scope.
See docs/ for more on the specific utilities currently implemented.
Building
Harakit utilities require a POSIX-compliant environment to compile, including a
C compiler and preprocessor (cc(1) and cpp(1) by default), an edition 2023 Rust
The coreutils require a POSIX-compliant environment to compile, including a C
compiler and preprocessor (cc(1) and cpp(1) by default), an edition 2023 Rust
compiler (rustc(1) by default), bindgen(1), and a POSIX-compliant make(1)
utility.

View File

@@ -4,7 +4,7 @@
.\" 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 2024-06-17 "Harakit X.X.X"
.TH DJ 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
dj \(en disk jockey
.\"

43
docs/eep.1 Normal file
View 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)

View File

@@ -4,7 +4,7 @@
.\" 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 FALSE 1 2024-06-06 "Harakit X.X.X"
.TH FALSE 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
.SH NAME
false \(en do nothing, unsuccessfully
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 FOP 1 2024-06-17 "Harakit X.X.X"
.TH FOP 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
fop \(en field operator
.\"

View File

@@ -3,7 +3,7 @@
.\" 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 HRU 1 2024-06-17 "Harakit X.X.X"
.TH HRU 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
hru \(en human readable units
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 INTCMP 1 2024-06-06 "Harakit X.X.X"
.TH INTCMP 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
.SH NAME
intcmp \(en compare integers
.\"

View File

@@ -3,7 +3,7 @@
.\" 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 MM 1 2024-06-17 "Harakit X.X.X"
.TH MM 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
mm \(en middleman
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 NPC 1 2024-06-17 "Harakit X.X.X"
.TH NPC 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
npc \(en show non-printing characters
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 RPN 1 2024-06-17 "Harakit X.X.X"
.TH RPN 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
rpn \(en reverse polish notation evaluation
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 SCRUT 1 2024-06-06 "Harakit X.X.X"
.TH SCRUT 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
.SH NAME
scrut \(en scrutinize file properties
.SH SYNOPSIS

View File

@@ -4,7 +4,7 @@
.\" 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 STR 1 2024-06-17 "Harakit X.X.X"
.TH STR 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
str \(en test string arguments
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 STRCMP 1 2024-06-17 "Harakit X.X.X"
.TH STRCMP 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
strcmp \(en compare strings
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 SWAB 1 2024-06-17 "Harakit X.X.X"
.TH SWAB 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
.SH NAME
swab \(en swap bytes
.\"

View File

@@ -4,7 +4,7 @@
.\" 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 TRUE 1 2024-06-06 "Harakit X.X.X"
.TH TRUE 1 2024-06-06 "Bonsai Core Utilites 0.13.11"
.SH NAME
true \(en do nothing, successfully
.\"

47
src/eep.rs Normal file
View 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])
}
}