Compare commits

...

2 Commits

4 changed files with 29 additions and 6 deletions

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-07-14 "Harakit X.X.X"
.TH DJ 1 2025-10-26 "Harakit X.X.X"
.SH NAME
dj \(en disk jockey
.\"

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 MM 1 2024-07-14 "Harakit X.X.X"
.TH MM 1 2025-11-01 "Harakit X.X.X"
.SH NAME
mm \(en middleman
.\"
@ -22,7 +22,9 @@ Catenate input files and write them to the start of each output file or stream.
.SH OPTIONS
.IP \fB-a\fP
Opens outputs for appending rather than updating.
Opens outputs for appending rather than updating. Implies the
.B -t
option.
.IP \fB-e\fP
Use the standard error as an output.
.IP \fB-t\fP
@ -59,6 +61,10 @@ unncessary.
.\"
.SH HISTORY
The \fB-t\fP option was originally the reverse functionality, as the default
behavior was to overwrite outputs. This was deemed counterintuitive and the
default behavior was changed.
This utility originally had a \fB-u\fP option for compatibility with cat(1p),
but this option is almost always default behavior in practice; therefore, it
was dropped both for simplicity and to expand the

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
* Copyright (c) 20242025 Emma Tebibyte <emma@tebibyte.media>
* Copyright (c) 2024 DTB <trinity@trinity.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*
@ -168,7 +168,7 @@ fn main() -> ExitCode {
let options = File::options()
/* dont truncate if -t is specified, append if -a is specified */
.truncate(t)
.truncate(!a && t)
.append(a)
/* enable the ability to create and write to files */
.create(true)

View File

@ -1,10 +1,12 @@
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
# Copyright (c) 20242025 Emma Tebibyte <emma@tebibyte.media>
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
MM_FILE!=mktemp /tmp/mm.XXXXXX
.PHONY: mm_tests
mm_tests: mm_args mm_help mm_stderr mm_remaining mm_remaining_options
@ -38,3 +40,18 @@ mm_remaining: $(BIN)/mm
mm_remaining_options:
! $(BIN)/mm -i README COPYING -o - 2>&1 | cut -d: -f2 \
| xargs test " -o" =
.PHONY: mm_append
mm_append:
$(BIN)/mm -i /dev/null -o $(MM_FILE)
printf 'test\nstring\nmulti-line\n' | $(BIN)/mm -o $(MM_FILE)
printf 'new line\n' | $(BIN)/mm -a -o $(MM_FILE)
$(BIN)/mm -i $(MM_FILE) | wc -l | xargs test 4 -eq
.PHONY: mm_no_truncate
mm_no_truncate:
$(BIN)/mm -i /dev/null -o $(MM_FILE)
printf 'test\nstring\nmulti-line\n' | $(BIN)/mm -o $(MM_FILE)
printf 'new line\n' | $(BIN)/mm -t -o $(MM_FILE)
$(BIN)/mm -i $(MM_FILE) | wc -l | xargs test 3 -eq