Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Clone for Shell? #79

Open
bzm3r opened this issue Jan 8, 2024 · 0 comments
Open

Implement Clone for Shell? #79

bzm3r opened this issue Jan 8, 2024 · 0 comments

Comments

@bzm3r
Copy link

bzm3r commented Jan 8, 2024

There are two fundamental parts to an xshell::Shell: https://docs.rs/xshell/latest/src/xshell/lib.rs.html#383

Both cwd and env have T in RefCell<T> that can be cloned, so a "deep clone" (not a RefCell clone) could be implemented for Shell. It would be useful to do this in order to create "related" shells (e.g. nix style development shells) from a current shell.

cwd can already be reported via current_dir, and PR #78 aims to expose similar functionality for env. Therefore, it would be possible to create a new shell (Shell::new()) that is a clone of an existing shell by setting its current working directory and environment variables appropriately using set_var (based on the output of the proposed vars_os method on the original shell).

So, implementing Clone would provide this functionality in an idiomatic form?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant