LINER(1) liner 0.5 - a small, single-file line editor SYNOPSIS sh liner.sh [FILE] sh liner.sh -h | --help | --manual | --about | --version liner [FILE] The last form assumes the script has been installed as liner. DESCRIPTION liner edits one text file through typed commands and numbered lines. It uses /bin/sh, awk, and ordinary Linux/OpenBSD base utilities. It does not require a compiler, curses, ncurses, readline, Python, Bash, or another editor. The ordinary command interface uses normal terminal line input. Its optional scrolling pager needs a VT/xterm-compatible terminal. Run without FILE for an empty, unnamed file. A nonexistent FILE starts empty and uses that path when saved. The parent directory must exist. Existing input must be a readable regular file without NUL bytes. The file and edited text may not exceed 8 MiB (8,388,608 bytes). The prompt is liner> when the text matches the saved state and liner*> when there are unsaved changes. Line numbers start at 1. Press Enter to run a command. Commands require their full, lowercase names. A partial name plus Enter shows suggestions without running a command. For example, ch suggests change and q suggests quit and quit!. COMMANDS show [FIRST [LAST]] Show every line, one line, or an inclusive range with line numbers. show 4 displays line 4; show 4 12 displays lines 4 to 12. show never pauses. Empty text is reported as (empty). page [FIRST [LAST]] Show the same numbered text in the optional pager. Output that fits on one screen is printed without taking over the terminal. If input or output is redirected, page behaves like show. See PAGER below. change LINE Show the existing line, then ask for its replacement at Text>. Enter exactly one line. An empty replacement is valid. insert LINE Ask for one line at Text>, then insert it before LINE. Use the line count plus one to append. For an empty file, use insert 1. delete FIRST [LAST] Delete one line or an inclusive range. There is no confirmation; undo can reverse the change while this process remains open. undo Restore the previous text snapshot. Undo remains available after saving and can make the document modified again. redo Restore the next snapshot after undo. A new edit after undo discards the later redo snapshots. write [FILE] Save to the current path, or use FILE as the new path. An unnamed file requires FILE. The remainder of the command is a literal filename, including spaces. Do not add shell quotes. A successful save-as changes the current path. See SAVING below. help Print the 13 command names on one line. manual Print the full built-in instructions, including About information. about Print the version, credits, and warning. quit Leave if the current bytes match the last saved bytes. Otherwise ask you to write the file or use quit!. quit! Discard unsaved edits and remove the temporary snapshots. Only show, page, change, insert, delete, and write accept arguments. Numeric ranges are inclusive and must be within the file. An empty command line does nothing. Commands do not run shell code. At Text>, backslashes and other text are literal. For example, typing \t inserts a backslash and the letter t, not a tab. Enter supplies one line only. The program does not provide its own readline-style command history or character editing; terminal line-input controls still apply. PAGER Up / Down Scroll one wrapped display row. Page Up/Page Down Scroll one screen. Enter / Space Scroll forward one screen. q Return to commands immediately, without Enter. Holding a scrolling key repeats when the terminal repeats that key. The pager stays open at the beginning and end. Long displayed lines wrap without changing the file. Resize is taken into account when the pager next processes input. Progress counts wrapped rows of the requested output, including any display annotations, rather than file bytes or logical source lines. The percentage indicates how far the bottom of the visible output has reached. At 100%, the bottom has reached the last display row. Narrow terminals show a shorter progress label or omit it if it cannot fit. COMMAND-LINE OPTIONS -h, --help Print the full built-in manual, then exit. --manual Print the same full manual, then exit. --about Print the version, credits, and warning, then exit. --version Print the version, then exit. Only one file or one informational option is accepted. To open a file whose name looks like an option, give a path such as ./--help. At the shell prompt, quote filenames normally: sh liner.sh 'my notes.txt' Inside liner, use write my notes.txt without adding quotes. Filenames containing a newline or carriage return are refused. SAVING The editing buffer is separate from the original file. write stages the current bytes in the destination directory, checks the staged bytes, and then replaces the destination. A save-as refuses to overwrite an unrelated existing file. The destination's parent must permit creating and replacing files. Before replacing the current file, liner checks its saved metadata and bytes. A changed or removed file requires a new path. Symbolic links and files with multiple hard links also require a new save path. A symbolic link can be read when opening a file, but is not replaced by write. These checks do not lock the file against another writer. New files are private (mode 600). Existing attributes are copied with cp -p before the new bytes are written; a reported copy failure cancels the save. Other metadata is not guaranteed to be preserved. New paths are created without overwriting a name created concurrently. A failed save leaves the editing buffer available for another attempt. This shell implementation does not call fsync and makes no guarantee that a completed save survives an immediate power failure. If a message says the file was written but the saved-state record or attributes could not be updated, reopen the written file before attempting another write. LINE ENDINGS AND TEXT Unchanged lines and their existing LF/CRLF endings are preserved. New lines use the first newline style present in the current text, or LF when no newline is present. Replacing a line keeps its existing ending. A missing final newline stays absent where possible. Appending after an unterminated last line inserts the separator needed between lines. An empty final line needs a terminating newline to remain a line, so making the final line empty can add one. Deleting the last line of an unterminated file leaves the new last line unterminated unless it is empty. A lone carriage return is text, not a line separator. Display escapes backslashes as \\, tabs as \t, and control or non-ASCII bytes as \xNN. UTF-8 bytes are preserved but displayed individually as escapes. Display escapes never change the stored text and are not an input language. There is no Unicode character-wise editing, search/ replace, syntax highlighting, internal clipboard, or configuration file. UNDO, EXIT, AND RECOVERY Each changed edit creates a complete text snapshot in a private temporary directory. Undo and redo select these exact-byte snapshots. Saving does not erase history. Many edits can therefore use substantially more temporary disk space than the file size itself. quit after saving and quit! remove the temporary directory. If command input ends with no unsaved changes, liner exits normally. If input ends with unsaved changes, or a handled signal ends the process, cleanup retains the unsaved text and prints: Unsaved text kept at: /temporary/directory/NUMBER Use the exact path printed for the current snapshot. The highest-numbered snapshot may be a redo state rather than your current text. Copy the retained file to a normal location before temporary storage is cleared: cp '/exact/path/printed/by/liner' recovered.txt sh liner.sh recovered.txt If input ends at Text>, the unfinished change is cancelled; any earlier unsaved edits are retained. With usual terminal settings, Ctrl-C exits and invokes cleanup. This differs from editor's Ctrl-C command prompt. A forced kill cannot run cleanup or print a recovery path. Temporary storage can disappear during reboot or routine cleanup. The snapshots are not a power-loss recovery guarantee, and there is no automatic recovery picker. Use write to save work to a regular destination. ENVIRONMENT AND REQUIREMENTS TMPDIR chooses the temporary directory parent; the default is /tmp. liner sets LC_ALL=C to keep processing and display byte-oriented and uses umask 077 for its temporary files and new destinations. Requirements include /bin/sh, awk, cat, chmod, cmp, cp, dd, ln, ls, mkfifo, mktemp, mv, od, rm, stty, tail, tr, and wc from the system base. No additional editor or paging program is invoked. INSTALL No build step is needed. Run sh liner.sh directly, or install locally: mkdir -p "$HOME/.local/bin" "$HOME/.local/share/man/man1" install -m 755 liner.sh "$HOME/.local/bin/liner" install -m 644 docs/liner.1 "$HOME/.local/share/man/man1/" export PATH="$HOME/.local/bin:$PATH" man -M "$HOME/.local/share/man" liner The script targets the base utilities on Linux and OpenBSD. EXIT STATUS 0 means a normal exit or successful informational option. 1 indicates an error, including input ending with unsaved edits. 2 indicates too many command-line arguments. Handled signals return 128 plus the signal number. Individual interactive command errors normally keep liner open. CREDITS design by remfan1994 published by ThatIAm.vip BLOODGUILT CURSE Cows aren't killers, and beef is the bloodshed of the innocent. www.bloodguiltcurse.net has the Bible study SEE ALSO docs/editor.txt, README.txt, editor(1), sh(1), awk(1)