mitnk / cicada

An old-school bash-like Unix shell written in Rust
https://hugo.wang/cicada/
MIT License
981 stars 50 forks source link

Support accessing subprocess stdin/out as file #42

Open pothos opened 2 years ago

pothos commented 2 years ago

Bash supports getting the FD of an opened pipe directly in the form /dev/fd/X which then can be used as file path by the spawned process.

Expected:

$ head <(echo a) <(echo b)
==> /dev/fd/63 <==
a

==> /dev/fd/62 <==
b

Got:

$ head <(echo a) <(echo b)
head: <echo: No such file or directory
head: a: No such file or directory
head: <echo: No such file or directory
head: b: No such file or directory

Same for >(CMD) which will use stdin instead of stdout.

mitnk commented 2 years ago

Thanks @pothos. I never use this feature in my limited use of Bash. I checked a bit and found it only useful in some cases, and it's not part of POSIX. So I'm not find the necessary of adding it to cicada.

Do you feel you depend on this feature very much when you're using a shell?

pothos commented 2 years ago

Since bash is the de-facto standard for a shell, I simply expected it to work ;) I use it from time to time as its quite useful for things like diff <(cmd1) <(cmd2) but mostly when I'm testing single parts of a script. Fyi, it's also supported by https://github.com/nuta/nsh

mitnk commented 2 years ago

Let's put this to to-do-list then. I just know nsh, which I saw it support input colors, which I always want to have in cicada haha!