From e674027b3ea285a94fb0c8bb32db88e639ba7963 Mon Sep 17 00:00:00 2001 From: DTB Date: Thu, 21 Mar 2024 20:40:19 -0600 Subject: [PATCH 01/12] Makefile: add sleep(1) --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index cbfe3a7..d564a3c 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,13 @@ scrut: build/bin/scrut build/bin/scrut: src/scrut.c build $(CC) $(CFLAGS) -o $@ src/scrut.c +.PHONY: sleep +sleep: build/bin/sleep +build/bin/sleep: src/sleep.rs build + $(RUSTC) $(RUSTFLAGS) + --extern sysexits=build/o/libsysexits.rlib \ + -o $@ src/sleep.rs + .PHONY: str str: build/bin/str build/bin/str: src/str.c build -- 2.30.2 From 82a941eee38b484967833ab11c401fd8eb2bf295 Mon Sep 17 00:00:00 2001 From: DTB Date: Thu, 21 Mar 2024 20:41:05 -0600 Subject: [PATCH 02/12] sleep(1): initial implementation --- src/sleep.rs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/sleep.rs diff --git a/src/sleep.rs b/src/sleep.rs new file mode 100644 index 0000000..f5af47d --- /dev/null +++ b/src/sleep.rs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 DTB + * 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_OK, EX_USAGE}; + +fn usage(s: &str) -> ExitCode { + eprintln!("Usage: {} [seconds]", s); + ExitCode::from(EX_USAGE as u8) +} + +fn main() -> ExitCode { + let argv = args().collect::>(); + + if argv.len() == 2 { + if let Ok(s) = argv[1].parse::() { + sleep(Duration::from_secs(s)); + ExitCode::from(EX_OK as u8) + } else { + usage(&argv[0]) + } + } else { + usage(&argv[0]) + } +} -- 2.30.2 From 82f6c46b64a4ef270a995cbd7a0ecb81c6ea55b3 Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 3 May 2024 21:22:07 -0600 Subject: [PATCH 03/12] Makefile: update sleep recipe --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 70ab13c..09110e3 100644 --- a/Makefile +++ b/Makefile @@ -120,8 +120,8 @@ build/bin/scrut: src/scrut.c build .PHONY: sleep sleep: build/bin/sleep -build/bin/sleep: src/sleep.rs build - $(RUSTC) $(RUSTFLAGS) +build/bin/sleep: src/sleep.rs build rustlibs + $(RUSTC) $(RUSTFLAGS) \ --extern sysexits=build/o/libsysexits.rlib \ -o $@ src/sleep.rs -- 2.30.2 From b06c1d5488614b077f9b50e64bab83263acf8722 Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 3 May 2024 21:22:38 -0600 Subject: [PATCH 04/12] sleep(1): reduce dependence on sysexits --- src/sleep.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sleep.rs b/src/sleep.rs index f5af47d..3226802 100644 --- a/src/sleep.rs +++ b/src/sleep.rs @@ -24,7 +24,7 @@ use std::{ }; extern crate sysexits; -use sysexits::{EX_OK, EX_USAGE}; +use sysexits::EX_USAGE; fn usage(s: &str) -> ExitCode { eprintln!("Usage: {} [seconds]", s); @@ -37,7 +37,7 @@ fn main() -> ExitCode { if argv.len() == 2 { if let Ok(s) = argv[1].parse::() { sleep(Duration::from_secs(s)); - ExitCode::from(EX_OK as u8) + ExitCode::SUCCESS } else { usage(&argv[0]) } -- 2.30.2 From 327c71c8ae52215818567a02c8536c73e6f4e72a Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 3 May 2024 21:29:49 -0600 Subject: [PATCH 05/12] sleep.1: import from trinity/src --- docs/sleep.1 | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/sleep.1 diff --git a/docs/sleep.1 b/docs/sleep.1 new file mode 100644 index 0000000..09cace0 --- /dev/null +++ b/docs/sleep.1 @@ -0,0 +1,48 @@ +.TH SLEEP 1 + +.SH NAME + +sleep \(en wait a moment + +.SH SYNOPSIS + +sleep +.RB [ seconds ] + +.SH DESCRIPTION + +Sleep waits the given amount of seconds before exiting. + +.SH DIAGNOSTICS + +Sleep exits successfully when the time specified has elapsed, or unsuccessfully +if the time fails to elapse or if invoked incorrectly. In the latter scenario +sleep will also print a usage synopsis. + +.SH BUGS + +User may still be tired after invoking sleep. + +.SH EXAMPLES + +The following invocation sleeps for five seconds. + +.RS +.R sleep 5 +.RE + +The following sh(1p) command line sleeps for five minutes, or for sixty +seconds, five times, using rpn(1) and xargs(1p). + +.RS +.R $ rpn 60 5 '*' | xargs sleep +.RE + +.SH COPYRIGHT + +Copyright (c) 2024 DTB. License AGPLv3+: GNU AGPL version 3 or later +. + +.SH SEE ALSO + +sleep(3) -- 2.30.2 From 003f5aeb1f65f08334beb4629f7e493fbb47dc7a Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 3 May 2024 21:30:39 -0600 Subject: [PATCH 06/12] Makefile: add sleep to the all recipe --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 09110e3..0099840 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \ CFLAGS += -I$(SYSEXITS) .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: # keep build/include until bindgen(1) has stdin support -- 2.30.2 From ba55c4c8e7812595c5f6141e5e9b5b29709928a5 Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 3 May 2024 21:32:10 -0600 Subject: [PATCH 07/12] sleep.1: add copyright header --- docs/sleep.1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/sleep.1 b/docs/sleep.1 index 09cace0..5b7108b 100644 --- a/docs/sleep.1 +++ b/docs/sleep.1 @@ -1,3 +1,8 @@ +.\" Copyright (c) 2024 DTB +.\" +.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license, +.\" visit . + .TH SLEEP 1 .SH NAME -- 2.30.2 From fe5c02059062f94c2123a94c5bcc7dd186809b63 Mon Sep 17 00:00:00 2001 From: emma Date: Wed, 29 May 2024 19:37:18 -0600 Subject: [PATCH 08/12] sleep(1): rename to eep(1) --- Makefile | 10 +++++----- src/{sleep.rs => eep.rs} | 0 2 files changed, 5 insertions(+), 5 deletions(-) rename src/{sleep.rs => eep.rs} (100%) diff --git a/Makefile b/Makefile index 0099840..34de4c8 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \ CFLAGS += -I$(SYSEXITS) .PHONY: all -all: dj false fop hru intcmp mm npc rpn scrut sleep str strcmp swab true +all: dj eep false fop hru intcmp mm npc rpn scrut str strcmp swab true build: # keep build/include until bindgen(1) has stdin support @@ -118,12 +118,12 @@ scrut: build/bin/scrut build/bin/scrut: src/scrut.c build $(CC) $(CFLAGS) -o $@ src/scrut.c -.PHONY: sleep -sleep: build/bin/sleep -build/bin/sleep: src/sleep.rs build rustlibs +.PHONY: eep +eep: build/bin/eep +build/bin/eep: src/eep.rs build rustlibs $(RUSTC) $(RUSTFLAGS) \ --extern sysexits=build/o/libsysexits.rlib \ - -o $@ src/sleep.rs + -o $@ src/eep.rs .PHONY: str str: build/bin/str diff --git a/src/sleep.rs b/src/eep.rs similarity index 100% rename from src/sleep.rs rename to src/eep.rs -- 2.30.2 From 99783281e15fa504c537fe9afc29a9f93fab3baf Mon Sep 17 00:00:00 2001 From: emma Date: Sat, 8 Jun 2024 23:47:48 -0600 Subject: [PATCH 09/12] eep.1: rename from sleep.1 --- docs/{sleep.1 => eep.1} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{sleep.1 => eep.1} (100%) diff --git a/docs/sleep.1 b/docs/eep.1 similarity index 100% rename from docs/sleep.1 rename to docs/eep.1 -- 2.30.2 From 22345245f13e2ca93d5c99f0629673a2d3d674fc Mon Sep 17 00:00:00 2001 From: emma Date: Sat, 8 Jun 2024 23:49:59 -0600 Subject: [PATCH 10/12] eep.1: renames sleep in the text --- docs/eep.1 | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/eep.1 b/docs/eep.1 index 5b7108b..cf809b0 100644 --- a/docs/eep.1 +++ b/docs/eep.1 @@ -1,17 +1,18 @@ .\" Copyright (c) 2024 DTB +.\" Copyright (c) 2024 Emma Tebibyte .\" .\" This work is licensed under CC BY-SA 4.0. To see a copy of this license, .\" visit . -.TH SLEEP 1 +.TH EEP 1 .SH NAME -sleep \(en wait a moment +eep \(en wait a moment .SH SYNOPSIS -sleep +eep .RB [ seconds ] .SH DESCRIPTION @@ -20,27 +21,27 @@ Sleep waits the given amount of seconds before exiting. .SH DIAGNOSTICS -Sleep exits successfully when the time specified has elapsed, or unsuccessfully +Eep exits successfully when the time specified has elapsed, or unsuccessfully if the time fails to elapse or if invoked incorrectly. In the latter scenario -sleep will also print a usage synopsis. +eep will also print a usage synopsis. .SH BUGS -User may still be tired after invoking sleep. +User may still be tired after invoking eep. .SH EXAMPLES -The following invocation sleeps for five seconds. +The following invocation eeps for five seconds. .RS -.R sleep 5 +.R eep 5 .RE -The following sh(1p) command line sleeps for five minutes, or for sixty +The following sh(1p) command line eeps for five minutes, or for sixty seconds, five times, using rpn(1) and xargs(1p). .RS -.R $ rpn 60 5 '*' | xargs sleep +.R $ rpn 60 5 '*' | xargs eep .RE .SH COPYRIGHT -- 2.30.2 From 43d9193252fe5d2b870e2139d216c7d043f7e540 Mon Sep 17 00:00:00 2001 From: emma Date: Sat, 8 Jun 2024 23:51:57 -0600 Subject: [PATCH 11/12] =?UTF-8?q?eep.1:=20can=E2=80=99t=20believe=20i=20mi?= =?UTF-8?q?ssed=20this?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/eep.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/eep.1 b/docs/eep.1 index cf809b0..150c5b6 100644 --- a/docs/eep.1 +++ b/docs/eep.1 @@ -17,7 +17,7 @@ eep .SH DESCRIPTION -Sleep waits the given amount of seconds before exiting. +Eep waits the given amount of seconds before exiting. .SH DIAGNOSTICS -- 2.30.2 From f521c309ab5c5cd3742fe474aba85075a5bd6376 Mon Sep 17 00:00:00 2001 From: emma Date: Wed, 26 Jun 2024 09:10:15 -0600 Subject: [PATCH 12/12] eep.1: Apply formatting changes --- docs/eep.1 | 53 +++++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/docs/eep.1 b/docs/eep.1 index 150c5b6..1032535 100644 --- a/docs/eep.1 +++ b/docs/eep.1 @@ -3,52 +3,41 @@ .\" .\" This work is licensed under CC BY-SA 4.0. To see a copy of this license, .\" visit . - +.\" .TH EEP 1 - .SH NAME - eep \(en wait a moment - +.\" .SH SYNOPSIS eep .RB [ seconds ] - +.\" .SH DESCRIPTION -Eep waits the given amount of seconds before exiting. - +Wait a specified number of seconds before exiting. +.\" .SH DIAGNOSTICS -Eep exits successfully when the time specified has elapsed, or unsuccessfully -if the time fails to elapse or if invoked incorrectly. In the latter scenario -eep will also print a usage synopsis. +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 -.SH BUGS - -User may still be tired after invoking eep. - -.SH EXAMPLES - -The following invocation eeps for five seconds. - -.RS -.R eep 5 -.RE - -The following sh(1p) command line eeps for five minutes, or for sixty -seconds, five times, using rpn(1) and xargs(1p). - -.RS -.R $ rpn 60 5 '*' | xargs eep -.RE +User may still be tired after invocation. +.\" +.SH AUTHOR +Written by DTB +.MT trinity@trinity.moe +.ME . +.\" .SH COPYRIGHT -Copyright (c) 2024 DTB. License AGPLv3+: GNU AGPL version 3 or later +Copyright \(co 2024 DTB. License AGPLv3+: GNU AGPL version 3 or later . - +.\" .SH SEE ALSO - -sleep(3) +.BR sleep (3p) +.BR sleep (1p) -- 2.30.2