commit 7fd18eb26d6768091036477bd34061b69d6044db Author: emma Date: Sun Jul 2 23:20:08 2023 -0600 initial commit 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