anishathalye / seashells

The official client for seashells.io 🐚
https://seashells.io
MIT License
708 stars 20 forks source link

ability to capture and distinguish between stderr and stdout #14

Closed ssbarnea closed 6 years ago

ssbarnea commented 6 years ago

Most applications do output to both stdout and stderr and it maybe extremely useful if seashells would be able to capture both and also to differentiate between them.

Example:

ccxc cxc | seashells                                                                                                                                                                                                            zsh: command not found: ccxc
serving at https://seashells.io/v/XBQADDt4

As seen the url contains no output because the entire output was on stderr.

I know that by redirecting stderr to stdout via 2>&1 i can assure that both endup printed.

Still this is not the same as capturing stderr and stdout separated and it would make impossible to distinguish between them.

Still, i seashells would execute the commands itself this would be possible, with a syntax like seashells -c "xxxdfdf d" the app would be able to fully control the stderr and stdin.

anishathalye commented 6 years ago

Hmm, this is an interesting idea.

A terminal output in general does not distinguish between how stdout and stderr are displayed, so it might be confusing if seashells somehow distinguishes between the two. How would you imagine the output being differentiated in the Seashells web interface?

I'd prefer to avoid adding additional complexity to Seashells; this feature would require changes to the client, the client-server protocol (to distinguish the two streams), and the web frontend, so it would be a pretty big change.

And if stdout and stderr can just be merged rather than being displayed distinctly, the standard 2>&1 achieves what we want, so it doesn't seem worthwhile to add complexity to Seashells to launch programs and capture their output.

ssbarnea commented 6 years ago

Special treatment for stderr would clearly not be easy to implement, lets keep this a different feature request.

Still ability to easily start a command would be extremely beneficial because it is just too easy (and harder) to forget to type the 2>&1 on each invocation.

Thus is why I propose alternative use as a "prefix" (launcher). If you want it can also be another executable. Use of shell aliases does not work in this case but I was able to create a shell function that does the trick:

function sea() {
    $* 2>&1 | seashells;
}

And now I can just do sea df instead of df 2>&1 | seashells, saving a lot of keystrokes.

anishathalye commented 6 years ago

Good point. I added a section to the readme about this: https://github.com/anishathalye/seashells#tips-and-tricks