News for hackers. Stuff that matters.
Re:CLI: Improved by skissane on Thursday August 30, 2018 @05:21PM (#17880897)
If Unix pipes gained support for exchanging some kind of out-of-band signalling messages, then CLI apps could tag their output as being in a particular format, or even the two ends of a pipe could negotiate about what format to use. If sending/receiving out-of-band messages was by some new API, then it could be done in a backwards compatible way. (e.g. if other end starts reading/writing/selecting/polling/etc without trying to send/receive a control message first, then the send/receive control message API returns some error code "other end doesn't support control messages")

I have suggested this before: https://news.ycombinator.com/item?id=14675847

(But I don't really care enough about the idea to try to implement it... it would need kernel changes plus enhancements to the user space tools to use it... but, hypothetically, if PTYs got this support as well as pipes, your CLI tool could mark its output as 'text/html', and then your terminal could embed a web browser right in the middle of your terminal window to display it.)

Re:CLI: Improved by ratboy666 on Thursday August 30, 2018 @06:38PM (#17881418)
I am not sure how this would work. rsh/ssh may be involved. I wouldn't even know how to express:

ssh carthoris ls /mnt/media/Movies | grep Spider

(this is just an example). Note that in this example, we have two processes running on two different machines. Indeed, the OSs and systems on these machines may be, um... different. Indeed, I routinely include "cloud" machines in pipelines. Indeed, with ssh, the -Y (or -X) option can introduce a GUI to a part of the command.

I have wished that shar was part of SUS. Also, I find that "exodus" is useful (across Linux anyway -- the systems have to be "reasonably" homogenous). https://github.com/intoli/exodus

Re:CLI: Improved by skissane on Thursday August 30, 2018 @08:32PM (#17882025)
> I am not sure how this would work. rsh/ssh may be involved.

In order for this to work over SSH, the SSH client and server would need to be enhanced to exchange this data, and also an SSH protocol extension would need to be defined to convey it across the network.

One might define IOCTLs that work on pipes and PTYs to send/receive control messages. So sshd would read control messages from the PTY and pass them over the network, and the SSH client would receive them and then pass them on to its own stdout using the same ICOTLs. (Alternatively, one might expand the existing control message support that recvmsg/sendmsg supply on sockets to work on pipes and ptys as well.)

Any program supporting such an out-of-band signalling mechanism would have to gracefully degrade when it is absent. If your SSH client or server, or some program in your pipeline, or your terminal emulator, etc, doesn't support them, just fall back on the same mechanisms used today to determine output/input formats.

(rsh is such a deprecated protocol, there would be no point in trying to extend it to support something like this.)

Re:CLI: Improved by h1d on Thursday August 30, 2018 @11:25PM (#17882695)
This would be excellent. Finally we get to view images on remote side (except by the iTerm hack) and view diff in a local GUI in the middle of a session?
Re:CLI: Improved by kevin_thibedeau on Thursday August 30, 2018 @10:05PM (#17882370)
Unix domain sockets. Bidirectional, and you can use datagrams to bypass the effort of framing data yourself.
Re:CLI: Improved by vram22 on Thursday August 30, 2018 @06:02PM (#17881201)
>your CLI tool could mark its output as 'text/html', and then your terminal could embed a web browser right in the middle of your terminal window to display it.

Ha ha, I had dreamed up something like this in one of my wilder imaginings, a while ago: A command-line shell at which you can type pipelines, involving some regular CLI commands, but also GUI commands as components, and when the pipeline is run, those GUIs will pop up in the middle of the pipeline, allow you to interact with them, and then any data output from them will go to the next component in the pipeline :) Don't actually know if the idea makes sense or would be useful.

Re:CLI: Improved by jolmg on Friday August 31, 2018 @12:24AM (#17882945)
Sure it makes sense. Just put `gvim /dev/stdin` in the pipeline you desire and write to stdout when you're done. You can add to your configuration to remap `ZZ` (which usually saves the file and exits) to `:wq! /dev/stdout` when stdout is not a terminal. I'm going to do that when I get back to my computer.
Re:CLI: Improved by vram22 on Friday August 31, 2018 @02:07PM (#17887654)
That sounds like a cool use of the concept. Will try it out. Thanks.
Re:CLI: Improved by h1d on Thursday August 30, 2018 @11:21PM (#17882668)
It does. For example, you could pipe an output of diff and a GUI diff viewer starts up and it's a whole lot easier to see or merge the context and even you may be able to launch a 'system default' app for that instead of a predefined app.

And another apparent one is image viewer or editor.

Re:CLI: Improved by v_lisivka on Thursday August 30, 2018 @07:33PM (#17881753)
Re:CLI: Improved by chriswarbo on Thursday August 30, 2018 @07:47PM (#17881817)
> A command-line shell at which you can type pipelines, involving some regular CLI commands, but also GUI commands as components, and when the pipeline is run, those GUIs will pop up in the middle of the pipeline, allow you to interact with them, and then any data output from them will go to the next component in the pipeline

There seems to be some precedent for this sort of thing. For example, DVTM can invoke a text editor as a "filter", where the editor UI is drawn on stderr and result saved to stdout.

Re:CLI: Improved by flukus on Thursday August 30, 2018 @11:34PM (#17882738)
> where the editor UI is drawn on stderr and result saved to stdout

I did some experimenting recently and found you can open a new /dev/tty file descriptor and tell curses to use this, the rest of the application can continue reading stdin and writing stdout as normal.

Re:CLI: Improved by type0 on Friday August 31, 2018 @11:07AM (#17886162)
I think you could use rofi for that, just insert it to the pipes and filter accordingly.
Re:CLI: Improved by vram22 on Friday August 31, 2018 @02:13PM (#17887687)
Thanks, had not heard of rofi. Just took a look. Seems like a useful tool.