From ef4e83c3d37668a49b6edc47c4c8c8612d53c92b Mon Sep 17 00:00:00 2001 From: emma Date: Sat, 8 Jul 2023 19:10:01 -0600 Subject: [PATCH] idk im drunk --- en | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/en b/en index 057ddad..ab2789e 100755 --- a/en +++ b/en @@ -8,6 +8,7 @@ # notice are preserved. This file is offered as-is, without any warranty. argv0="$0" +exec >&2 &2 @@ -25,14 +26,14 @@ a – appends a line to the current buffer.\n\ c – clears the screen.\n\ d – deletes a line.\n\ e – evaluates a command in the shell environment.\n\ -h – displays this help message.\n\ +? – displays this help message.\n\ i – inserts a line into the buffer at position line.\n\ p – prints the current buffer.\n\ q – terminates editing.\n\ r – applies a regular expression to the current buffer.\n\ w – writes the current buffer to the file.\n\ \n\ -To learn more about a command verb, type \`h verb'.\n\ +To learn more about a command verb, type \`? verb'.\n\ en(1) Copyright (c) 2023 Emma Tebibyte\n")" while test -n "$1"; do @@ -55,6 +56,14 @@ while test -n "$1"; do read -r command args case $command in + "?") + if test -z "$args"; then + printf "%s: %s\n" "$argv0" "$help" + else + printf "%s: Command-specific help not implemented.\n" "$argv0" 1>&2 + continue + fi + ;; "a") read -r append content="$(printf "%s\n%s" "$content" "$append")" @@ -66,21 +75,13 @@ while test -n "$1"; do printf "%s: d: Command not implemented.\n" "$argv0" 1>&2 ;; "e") - eval "$args" - ;; - "h") - if test -z "$args"; then - printf "%s: %s\n" "$argv0" "$help" - else - printf "%s: Command-specific help not implemented.\n" "$argv0" 1>&2 - continue - fi + eval "$args" || true ;; "i") printf "%s: i: Command not implemented.\n" "$argv0" 1>&2 ;; "p") - out="$(syntax_h "$content" || printf "%s\n" "$content")" + out="$(syntax_h "$content" 2>/dev/null || printf "%s\n" "$content")" printf "%s" "$out" | nl -ba ;; "q") @@ -105,6 +106,9 @@ while test -n "$1"; do "w") printf "%s\n" "$content" > "$1" ;; + *) + printf "%s: %s: No such command.\n" "$argv0" "$command" + ;; esac done