mitnk / cicada

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

[WIP] Bash fallback feature #48

Closed danimesq closed 1 year ago

danimesq commented 1 year ago

If successfully worked and merged, this PR will solve the issue https://github.com/mitnk/cicada/issues/43.

Current status: coding was made by GPT-4 and some required stuff was missed by the AI. Failed to compile, with 2 errors (src/main.rs) in the following output:

cicada on  main is 📦 v0.9.38 via 🦀 v1.72.0 ❯ cargo build Compiling cicada v0.9.38 (/home/daniella/Desktop/cicada) error[E0599]: no variant or associated item named new found for enum linefeed::Command in the current scope --> src/main.rs:170:47 | 170 | let output = Command::new("bash") | ^^^ variant or associated item not found in Command

error[E0063]: missing field gid in initializer of cicada::CommandResult --> src/main.rs:177:36 | 177 | let last = CommandResult { | ^^^^^^^^^^^^^ missing gid

Some errors have detailed explanations: E0063, E0599. For more information about an error, try rustc --explain E0063. error: could not compile cicada (bin "cicada") due to 2 previous errors

danimesq commented 1 year ago

@mitnk, if you re-consider about supporting a Bash fallback, now you have a good base and incentive to start on.

Feel free to analyse the few lines GPT-4 has added, and how to fix it in order to work.

mitnk commented 1 year ago

Hey @danimesq Thanks for putting this in. I'm not sure I want to add this feature, as a counter-part to bash, cicada will not use bash as a fallback/dependency I would say.

And in current code of your PR, it will not work, if I run ls file-doesnt-exist.txt, it will return non-0 and I don't think we should run it again with bash, right?

I know xonsh has fallbacks to other shells: users may have bad RC file, which would cause xonsh fail to bootup, in this case, it will exec to bash etc. But this is not the case in our context.

mitnk commented 1 year ago

cicada is itself functional for daily use. But I do use bash (for scripting things) - I would open a file foo.sh with following in it:

#!/bin/bash
bash scripting code ...
bash scripting code ...
...

And invoke it with bash foo.sh, ./foo.sh, or just foo.sh if it's put in the PATH.