peek(1) #93

Open
trinity wants to merge 5 commits from peek into main
Owner

peek(1) is a utility that reads standard input and writes to given outputs without echoing to the terminal. It has a number of features that make safer usage convenient and both the code and the man page are very cleanly written. This tool's utility is obvious in the examples; while shell scripts shouldn't accept secrets, if they were to do so this is a thoughtfully designed utility for that task.

This is imported from my source tree with slight tweaks for this repository. @silt helped review this code when it was first written (four months ago).

mm(1) isn't suited for this task because it doesn't prevent terminal echoing. The shell built-in read doesn't either. The featureset of this utility wouldn't make sense for any other one, either (-1 could be | head -n 1, -e could be | tee /dev/stderr, -n could be | tr -d \\n, -o is a default everywhere, -p is a pipe, and -t doesn't make sense elsewhere).

peek(1) is a utility that reads standard input and writes to given outputs *without* echoing to the terminal. It has a number of features that make safer usage convenient and both the code and the man page are very cleanly written. This tool's utility is obvious in the examples; while shell scripts *shouldn't* accept secrets, if they were to do so this is a thoughtfully designed utility for that task. This is [imported from my source tree](https://git.tebibyte.media/trinity/src/src/branch/main/peek) with slight tweaks for this repository. @silt helped review this code when it was first written (four months ago). mm(1) isn't suited for this task because it doesn't prevent terminal echoing. The shell built-in `read` doesn't either. The featureset of this utility wouldn't make sense for any other one, either (`-1` could be `| head -n 1`, `-e` could be `| tee /dev/stderr`, `-n` could be `| tr -d \\n`, `-o` is a default everywhere, `-p` is a pipe, and `-t` doesn't make sense elsewhere).
trinity added the
enhancement
label 2024-04-17 23:18:25 +00:00
trinity added 1 commit 2024-04-17 23:18:25 +00:00
trinity requested review from emma 2024-04-17 23:24:29 +00:00
trinity requested review from silt 2024-04-17 23:24:30 +00:00
emma requested changes 2024-04-18 04:34:15 +00:00
@ -0,0 +19,4 @@
.SH DESCRIPTION
Peek reads input from standard input with terminal echo disabled, which may be
Owner

Peek reads input from standard input with terminal echo disabled,

Read input from the standard input with terminal echo disabled.

which may be useful to prevent secrets being spied upon by adversaries watching a user's
screen.

Should this be placed in a RATIONALE section?

> Peek reads input from standard input with terminal echo disabled, Read input from the standard input with terminal echo disabled. > which may be useful to prevent secrets being spied upon by adversaries watching a user's screen. Should this be placed in a RATIONALE section?
trinity marked this conversation as resolved
docs/peek.1 Outdated
@ -0,0 +45,4 @@
.B -o
.RS
Configures peek to output to standard output.
Owner

“[...] the standard output”

“[...] the standard output”
trinity marked this conversation as resolved
@ -0,0 +48,4 @@
Configures peek to output to standard output.
.RE
.B -p
Owner

What is the benefit to this over using a shell pipe?

What is the benefit to this over using a shell pipe?
trinity marked this conversation as resolved
docs/peek.1 Outdated
@ -0,0 +94,4 @@
.R $ env -i PATH="$PATH" peek -1tp htpasswd -nBi _ | cut -d : -f 2
.RE
This is a POSIX sh(1) command line that lets a user blindly write into a text
Owner

Either:

This is a POSIX shell [...]

or:

This is an sh(1p) [...]

Either: > This is a POSIX shell [...] or: > This is an sh(1p) [...]
trinity marked this conversation as resolved
Owner

Could this functionality be attained using a combination of existing or hypothetical utilities and shell features? We should consider whether this utility should be necessary for its use case.

Could this functionality be attained using a combination of existing or hypothetical utilities and shell features? We should consider whether this utility should be necessary for its use case.
trinity added 3 commits 2024-04-18 16:04:33 +00:00
Author
Owner

Could this functionality be attained using a combination of existing or hypothetical utilities and shell features? We should consider whether this utility should be necessary for its use case.

Yes, actually. After rethinking it I rewrote the utility to be as simple as possible (and have -t be the default as it should have been). The man page has been updated to match, including incorporating all of your comments which I found to be useful.

> Could this functionality be attained using a combination of existing or hypothetical utilities and shell features? We should consider whether this utility should be necessary for its use case. Yes, actually. After rethinking it I rewrote the utility to be as simple as possible (and have `-t` be the default as it should have been). The man page has been updated to match, including incorporating all of your comments which I found to be useful.
trinity requested review from emma 2024-04-18 16:08:09 +00:00
trinity added 1 commit 2024-04-18 16:15:00 +00:00
emma changed title from peek(1) to WIP: peek(1) 2024-04-25 01:59:50 +00:00
emma changed title from WIP: peek(1) to peek(1) 2024-04-25 01:59:58 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b peek main
git pull origin peek

Step 2:

Merge the changes and update on Forgejo.
git checkout main
git merge --no-ff peek
git push origin main
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: bonsai/coreutils#93
No description provided.