config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 88fd38406ba91e38fae963af580168cfcddf2ce2
parent 71e3222cdf4cf7ef072d7e1b0baf9fe4ec0f567c
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Thu, 25 Mar 2021 20:01:33 -0700

Add shell function to ease in-place file editing

The bwrite function redirects stdin into a temporary file and, once
complete, moves it to the given file. This allows you to easily
write to the input file.

Diffstat:
Mlocal/shell/.config/shell/etc | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/local/shell/.config/shell/etc b/local/shell/.config/shell/etc @@ -13,3 +13,10 @@ tp() { *) printf '%s: arguments must be 'y' or 'n'\n' $__progname;; esac } + +# e.g. grep -i ^a <words | bwrite words +bwrite() ( + tmp="$(mktemp -t proc-XXXXXXXXXX)" + cat >"$tmp" + mv "$tmp" "$1" +)