yash-rs icon indicating copy to clipboard operation
yash-rs copied to clipboard

Implementing shell environment

Open magicant opened this issue 4 years ago • 2 comments

This is a tracking issue for implementation of shell environment.

Items

  • System-managed attributes
    • [x] File descriptors *
    • [x] Working directory *
    • [x] File creation mask (umask) * b9881be9b17b63d31dd9a2f33c6de4a0d4d6e310
    • [x] Limits (ulimit) * c751c80743e71ba237555386cbd9b10bb0233531
    • [x] Spent times (times) baf273da9867d5969416a36b0f772198d5535369
    • [ ] Real/effective/saved-set user/group
  • System-managed attributes behind application-managed ones
    • [x] Traps * #109
    • [x] Jobs * #153 #154
      • [x] Current and previous jobs f548ab92d21fc266649a77feb6af80117d262ed8
      • [x] Parsing job IDs 8d78200d7a12592af1259caf55b7bad7957d77a4
  • Application-managed attributes
    • [ ] Parameters and variables *
      • [x] Local/global variables
      • [x] Positional parameters #107
      • [x] Special parameters
        • [x] $?
        • [x] $$ 6c3d04d
        • [x] $0 83d54d93198e8202700f9bde267ca0250a94aefa
      • [ ] #217
    • [x] Functions *
    • [x] Built-ins #33
    • [x] Options * #148
      • [ ] Mutually exclusive options
    • [x] Aliases *
    • [x] Execution context stack
    • [x] Controlling terminal file descriptor 1bb5a7d1ab30c719afe07ba686178e87fc2b68d3 bb7a3ff4b7a0fb10acb7840c583dc28b0ce0c9e1
    • [ ] Command history
  • Attributes that possibly do not have to be in the environment because they're not copied when forking a subshell.
    • [x] Files on disks
    • [ ] Line-editing configuration (key bindings and completion settings)

Items marked * are defined in POSIX.

Possible optimizations

  • [ ] Virtual subshell: executing a synchronous subshell in the current process rather than in a child process

magicant avatar Feb 09 '21 15:02 magicant

It may be helpful to have a set of internally used file descriptors as one of application-managed attributes. Such FDs can be redirections' saved FD, pipes for sending here-document contents, interactive shell's tty, etc. Such FDs are invisible from the user, so they must move to other unused FDs when the user performs redirections on them. We can use Rc<Cell<Fd>> to keep track of where these FDs moved.

magicant avatar Sep 24 '21 16:09 magicant

The CLOEXEC flag indicates whether an FD is internal, so we don't necessarily need an FD set. We don't have to think about FDs moving as long as we don't support overwriting internal FDs.

magicant avatar Jan 12 '23 15:01 magicant