forked from bonsai/harakit
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
f1f5ac1788 | |||
7f59c3b617 | |||
9ef6289e00 | |||
ba55c4c8e7 | |||
003f5aeb1f | |||
327c71c8ae | |||
b06c1d5488 | |||
82f6c46b64 | |||
81c657ec3e | |||
9093b06166 | |||
d8b54fdbf5 | |||
f6aac60aee | |||
82a941eee3 | |||
e674027b3e |
14
Makefile
14
Makefile
@ -17,6 +17,8 @@
|
|||||||
DESTDIR ?= dist
|
DESTDIR ?= dist
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
|
MANDIR != [ $(PREFIX) = / ] && printf '/usr/share/man\n' \
|
||||||
|
|| printf '/share/man\n'
|
||||||
SYSEXITS != printf '\043include <sysexits.h>\n' | cpp -M - | sed 's/ /\n/g' \
|
SYSEXITS != printf '\043include <sysexits.h>\n' | cpp -M - | sed 's/ /\n/g' \
|
||||||
| sed -n 's/sysexits\.h//p' || printf 'include\n'
|
| sed -n 's/sysexits\.h//p' || printf 'include\n'
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ 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 false fop hru intcmp mm npc rpn scrut sleep str strcmp swab true
|
||||||
|
|
||||||
build:
|
build:
|
||||||
# keep build/include until bindgen(1) has stdin support
|
# keep build/include until bindgen(1) has stdin support
|
||||||
@ -42,7 +44,7 @@ clean:
|
|||||||
dist: all
|
dist: all
|
||||||
mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
|
mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
|
||||||
cp build/bin/* $(DESTDIR)/$(PREFIX)/bin
|
cp build/bin/* $(DESTDIR)/$(PREFIX)/bin
|
||||||
cp docs/*.1 $(DESTDIR)/$(PREFIX)/share/man/man1
|
cp docs/*.1 $(DESTDIR)/$(PREFIX)/$(MANDIR)/man1
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: dist
|
install: dist
|
||||||
@ -102,7 +104,6 @@ mm: build/bin/mm
|
|||||||
build/bin/mm: src/mm.c build
|
build/bin/mm: src/mm.c build
|
||||||
$(CC) $(CFLAGS) -o $@ src/mm.c
|
$(CC) $(CFLAGS) -o $@ src/mm.c
|
||||||
|
|
||||||
|
|
||||||
.PHONY: npc
|
.PHONY: npc
|
||||||
npc: build/bin/npc
|
npc: build/bin/npc
|
||||||
build/bin/npc: src/npc.c build
|
build/bin/npc: src/npc.c build
|
||||||
@ -118,6 +119,13 @@ 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: sleep
|
||||||
|
sleep: build/bin/sleep
|
||||||
|
build/bin/sleep: src/sleep.rs build rustlibs
|
||||||
|
$(RUSTC) $(RUSTFLAGS) \
|
||||||
|
--extern sysexits=build/o/libsysexits.rlib \
|
||||||
|
-o $@ src/sleep.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
|
||||||
|
57
README
57
README
@ -1,27 +1,27 @@
|
|||||||
“Seek not to walk the path of the masters; seek what they sought.”
|
For the Bonsai coreutils, a better Unix toolset, please visit
|
||||||
– Matsuo Basho
|
<https://git.tebibyte.media/bonsai/coreutils>.
|
||||||
|
|
||||||
The Bonsai core utilities are the result of the careful examination of the
|
wwwww /
|
||||||
current state of POSIX and Unix utilies. The Unix Philosophy, “do one thing and
|
wWWWWWw /_ _____ _ * "It's not a very good tree, but
|
||||||
do it well” is its core but these tools do not cling to the names of the past.
|
w|||w / \/ \ / | /\ / /|/ occasionally it bears fruit!"
|
||||||
|
_,|||._ _/\__/|__// /_/_|_/_//|__
|
||||||
|
bonsix : "BOHN zix" : "Bonsai" but "POSIX"
|
||||||
|
|
||||||
The era of the original Unix tools has been long and fruitful, but they have
|
The excellent Bonsai core utilities are the result of the careful examination
|
||||||
their flaws. The new, non-POSIX era of this project started with frustration
|
of the current state of POSIX and Unix utilities, ironing out wrinkles in the
|
||||||
with the way certain tools work and how other projects that extend POSIX don’t
|
implementations that ended up being worn by the POSIX standard. Bonsai's
|
||||||
make anything better.
|
guiding quote is this one from Matsuo Basho:
|
||||||
|
|
||||||
This project will not follow in the footsteps of GNU; extensions of POSIX will
|
"Seek not to walk the path of the masters; seek what they sought."
|
||||||
not be found here. GNU extensions are a gateway to the misuse of the shell. The
|
|
||||||
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.
|
Unlike Bonsai, Bonsix intends to walk the path of the masters, implementing a
|
||||||
|
POSIX userland under an AGPLv3 license and taking inspiration from the
|
||||||
|
practices used by Bonsai.
|
||||||
|
|
||||||
Building
|
Building
|
||||||
|
|
||||||
The coreutils require a POSIX-compliant environment to compile, including a C
|
Bonsix requires an existing POSIX-compliant environment to compile, including a
|
||||||
compiler and preprocessor (cc(1) and cpp(1) by default) with the -idirafter
|
C compiler and preprocessor (cc(1) and cpp(1) by default) and a POSIX-compliant
|
||||||
flag, a Rust compiler (rustc(1) by default), bindgen(1), and a POSIX-compliant
|
|
||||||
make(1) utility.
|
make(1) utility.
|
||||||
|
|
||||||
To build and install:
|
To build and install:
|
||||||
@ -32,29 +32,6 @@ $ make PREFIX="/your/preferred/location" install
|
|||||||
To build with a different compiler than the default:
|
To build with a different compiler than the default:
|
||||||
|
|
||||||
$ make CC=clang
|
$ make CC=clang
|
||||||
$ make RUSTC=gccrs
|
|
||||||
|
|
||||||
To test the utilities:
|
|
||||||
|
|
||||||
$ make test
|
|
||||||
|
|
||||||
To remove all untracked files:
|
|
||||||
|
|
||||||
$ make clean
|
|
||||||
|
|
||||||
Read More
|
|
||||||
|
|
||||||
An Introduction to the Unix Shell
|
|
||||||
<https://porkmail.org/era/unix/shell>
|
|
||||||
|
|
||||||
Master Foo and the Ten Thousand Lines
|
|
||||||
<http://www.catb.org/~esr/writings/unix-koans/ten-thousand.html>
|
|
||||||
|
|
||||||
Master Foo Discourses on the Unix-Nature
|
|
||||||
<http://www.catb.org/~esr/writings/unix-koans/unix-nature.html>
|
|
||||||
|
|
||||||
Shell Programming!
|
|
||||||
<https://tldp.org/LDP/abs/html/why-shell.html>
|
|
||||||
|
|
||||||
--
|
--
|
||||||
Copyright © 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
Copyright © 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
||||||
|
47
src/sleep.rs
Normal file
47
src/sleep.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));
|
||||||
|
ExitCode::SUCCESS
|
||||||
|
} else {
|
||||||
|
usage(&argv[0])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usage(&argv[0])
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user