initial commit
This commit is contained in:
commit
7fd18eb26d
63
en
Executable file
63
en
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user