Regarding:
Are there any use cases for being able to paste control characters (other than \t,\r,\n) into a terminal?
Your interaction with TUIs is via these control characters. Being able to paste them means you can use this feature to semi-automate your interaction with TUI programs.
Some time ago, I saved my department many hours of hurried work of manually entering hundreds of records of multiple fields in TUI forms, by taking the data we needed to enter from a CSV, interpolating the control characters needed to navigate the TUI (via sed
I think), validating the result, and pasting it into the terminal. All taking a few minutes.
Showing them this was like adding an import feature to every form of the TUI program. They found it to be a very useful technique, a real timesaver.
Depending on the case, though, this might be kind of dangerous. If an input value is invalid or a control sequence is wrong and the TUI program responds unexpectedly, the paste won't quit; it'll keep going and do who knows what with the TUI program.
In our case, it was simple to ensure that the inputs were valid, testing a cycle (enough of the paste to input 1 record and return to starting position) was enough to also ensure that the control characters were ok, and we also took a moment to consider the worst that could happen if at any point this particular paste could be interpreted out of context.
This was a quick and dirty ad-hoc solution to a somewhat rare problem. Given more time, it might've been better to learn how to write expect
scripts first to at least quit on the first detected error and report where it got stuck. We were somewhat in a hurry though, so we couldn't consider something that we needed to invest time learning first, especially when we already accepted how long it would take to do it manually. The simplicity and ease of pasting our interaction with a TUI in a few minutes is what provided value over using an expect
script.