Other rules for command line tools: 1. Don’t assume a terminal type. Look at `TERM` and use termcap/terminfo or a library built atop them for anything beyond line-oriented plain text output, or least assume a plain teletype unless you specifically recognize the user’s terminal type. 2. Don’t assume the presence of a terminal at all. Check `isatty()` before doing anything fancy, and be sure to work without a terminal…
I've never heard of the `@/path/to/file` convention, nor ever seen anything that documented using or supporting it. Do you have any examples of tools that do use it (maybe I've just never seen it in the documentation)?
"Rules" that terminal programs follow
151–153 of 153 posts
Re: "Rules" that terminal programs follow
#152Earlier quoted context omitted.
I read up on this and "cooked but character-by-character" is apparently something called "cbreak mode" (or "rare mode").
According to stty(1), ”cbreak” is a negative alias of “icanon”, which simply enables the special functions of the ‘erase’ (backspace), ‘kill’ (Ctrl-U), ‘werase’ (Ctrl-W), and ‘rprnt’ (Ctrl-R) keybindings. “cooked” mode includes “icanon”. So no, I do not think that what you wrote is correct. From what I can tell, the line-by-line mode is “extproc”.
min N with -icanon, set N characters minimum for a completed read
which suggests that if you set -icanon (e.g. cbreak) then reads may complete after 1 character.Also on macOS the documentation for cbreak is different, it lists a bunch of settings including -icanon, it's Linux that makes it literally an alias for -icanon.
Re: "Rules" that terminal programs follow
#153As an addendum to Rule 7, `cd -` takes you to the last opened directory. Or is `cd` considered part of the terminal emulator's job, as a built-in?
I don't think it's part of the terminal emulator (e.g. xterm, gnome-terminal) but the shell (bash, zsh, etc.). You're correct that it's not something that's implemented as an external program though; the "current directory" is state for a currently running terminal session, so changing that state is done via the shell interface (either directly by built-in commands like cd or indirectly via external commands that use…