From 7fd18eb26d6768091036477bd34061b69d6044db Mon Sep 17 00:00:00 2001 From: emma Date: Sun, 2 Jul 2023 23:20:08 -0600 Subject: [PATCH] initial commit --- en | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 en diff --git a/en b/en new file mode 100755 index 0000000..fd18180 --- /dev/null +++ b/en @@ -0,0 +1,63 @@ +#!/bin/sh -e + +# Copyright (c) 2023 Emma Tebibyte +# 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. + +argv0="$0" + +if test -z "$1"; then + printf "Usage: %s file...\n" "$argv0" +fi + +while test -n "$1"; do + content="$(cat "$1")" + cat "$1" + + while true; do + printf ">> " + read -r command args + + case $command in + "c") + clear + ;; + "d") + printf "%s: d: Command not implemented.\n" "$argv0" + ;; + "i") + printf "%s: i: Command not implemented.\n" "$argv0" + ;; + "p") + printf "%s\n" "$content" + ;; + "q") + if test -n "$(printf "%s\n" "$content" | diff "$1" -)" + then + printf "%s: %s: Unsaved changes in the buffer. Quit anyway? [y/N] " \ + "$argv0" \ + "$1" + read quit + if [ "$quit" = "y" ]; then + break + else + continue + fi + else + break + fi + ;; + "s") + content="$(printf "%s" "$content" | sed "$args")" + ;; + "w") + printf "%s\n" "$content" > "$1" + ;; + esac + done + + shift +done