From e351b2bc9875f7943eb1bd4b4d75ef83ae9a10a1 Mon Sep 17 00:00:00 2001 From: Adam <56338480+adastx@users.noreply.github.com> Date: Thu, 9 Jun 2022 00:02:27 +0200 Subject: Added doasedit script to repo --- .local/bin/doasedit | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 .local/bin/doasedit (limited to '.local/bin') diff --git a/.local/bin/doasedit b/.local/bin/doasedit new file mode 100755 index 0000000..0d2c9c9 --- /dev/null +++ b/.local/bin/doasedit @@ -0,0 +1,47 @@ +#!/bin/sh -e + +help() { + cat - >&2 < "$tmp" + elif [ -r "$file" ]; then + cat "$file" > "$tmp" + fi + + tmpcopy="$(mktemp)" + cat "$tmp" > "$tmpcopy" + + ${EDITOR:-vi} "$tmp" + + if cmp -s "$tmp" "$tmpcopy"; then + echo 'File unchanged, exiting...' + else + doas dd if="$tmp" of="$file" + echo 'Done, changes written' + fi + + rm "$tmp" "$tmpcopy" +done + -- cgit v1.2.3-70-g09d2