web_shell

command module
v0.0.0-...-bf0f43f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2023 License: MIT Imports: 22 Imported by: 0

README

Proof-of-concept shell interface outside a terminal.

This works with bash and the Go sh/interp package.

Build with:

go generate
go build

Run:

./web_shell
# Or, to get rid of the controlling terminal:
# (requires using `kill` to exit)
setsid ./web_shell

Clean:

rm web_shell lib/inject_tcsetpgrp.so

Shift-Enter to enter a new line.
Ctrl-C to interrupt a running command.
Double-click to collapse a command's output.

It's horrible in many ways. Most notably, the shell interpreter instance is global.

Documentation

Overview

Prototype Shell UI, for the Go sh package and external shell interpreters.

Each command is allocated a pty for stdout and a (named) pipe for stderr. An anonymous pipe would be better, but would require fd passing.

This doesn't work for every command:

  • If `less` can't open `/dev/tty`, it READS from stderr! Not stdin. (because stdin might be the read end of a pipe) alias less="less 2<&0" works, but wouldn't work in a pipe.
  • sudo reads from /dev/tty by default, but you can tell it to use stdin with `sudo -S`. alias sudo="sudo -S" works.

Apparently according to POSIX, stderr is supposed to be open for both reading and writing...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL