idk im drunk
This commit is contained in:
parent
d642abc3f3
commit
ef4e83c3d3
28
en
28
en
@ -8,6 +8,7 @@
|
|||||||
# notice are preserved. This file is offered as-is, without any warranty.
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
argv0="$0"
|
argv0="$0"
|
||||||
|
exec >&2 </dev/tty
|
||||||
|
|
||||||
if test -z "$1"; then
|
if test -z "$1"; then
|
||||||
printf "Usage: %s file...\n" "$argv0" 1>&2
|
printf "Usage: %s file...\n" "$argv0" 1>&2
|
||||||
@ -25,14 +26,14 @@ a – appends a line to the current buffer.\n\
|
|||||||
c – clears the screen.\n\
|
c – clears the screen.\n\
|
||||||
d – deletes a line.\n\
|
d – deletes a line.\n\
|
||||||
e – evaluates a command in the shell environment.\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\
|
i – inserts a line into the buffer at position line.\n\
|
||||||
p – prints the current buffer.\n\
|
p – prints the current buffer.\n\
|
||||||
q – terminates editing.\n\
|
q – terminates editing.\n\
|
||||||
r – applies a regular expression to the current buffer.\n\
|
r – applies a regular expression to the current buffer.\n\
|
||||||
w – writes the current buffer to the file.\n\
|
w – writes the current buffer to the file.\n\
|
||||||
\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")"
|
en(1) Copyright (c) 2023 Emma Tebibyte\n")"
|
||||||
|
|
||||||
while test -n "$1"; do
|
while test -n "$1"; do
|
||||||
@ -55,6 +56,14 @@ while test -n "$1"; do
|
|||||||
read -r command args
|
read -r command args
|
||||||
|
|
||||||
case $command in
|
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")
|
"a")
|
||||||
read -r append
|
read -r append
|
||||||
content="$(printf "%s\n%s" "$content" "$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
|
printf "%s: d: Command not implemented.\n" "$argv0" 1>&2
|
||||||
;;
|
;;
|
||||||
"e")
|
"e")
|
||||||
eval "$args"
|
eval "$args" || true
|
||||||
;;
|
|
||||||
"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
|
|
||||||
;;
|
;;
|
||||||
"i")
|
"i")
|
||||||
printf "%s: i: Command not implemented.\n" "$argv0" 1>&2
|
printf "%s: i: Command not implemented.\n" "$argv0" 1>&2
|
||||||
;;
|
;;
|
||||||
"p")
|
"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
|
printf "%s" "$out" | nl -ba
|
||||||
;;
|
;;
|
||||||
"q")
|
"q")
|
||||||
@ -105,6 +106,9 @@ while test -n "$1"; do
|
|||||||
"w")
|
"w")
|
||||||
printf "%s\n" "$content" > "$1"
|
printf "%s\n" "$content" > "$1"
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
printf "%s: %s: No such command.\n" "$argv0" "$command"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user