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 command substitution #13

Open
Arcterus opened this issue Jul 3, 2018 · 2 comments
Open

Implement command substitution #13

Arcterus opened this issue Jul 3, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@Arcterus
Copy link
Contributor

Arcterus commented Jul 3, 2018

The only issue at the moment is getting the output. Running the program and waiting for it should work fine.

@Arcterus Arcterus added the enhancement New feature or request label Jul 3, 2018
@Arcterus
Copy link
Contributor Author

I've got this working for the most part. I need to separate it from my piping-related changes though. Backtick-style substitution still doesn't work at the moment (due to parsing). There are also some issues with setting variables and whatnot in a substitution as I want to avoid forking (and thus creating a real subshell) unless absolutely necessary.

@Arcterus
Copy link
Contributor Author

Basically what needs to happen to avoid forking is we need to have locality for variables (in addition to file descriptors, which already have locality). There are two easy ways to do this:

  1. Use the Locality type currently used for file descriptors and, like file descriptors, loop through every variable and increment the count for Locality::Local variables. This is pretty easy to do as we already have the necessary types and such, but could become slower than forking given enough variables.
  2. Give the current Environment a parent Environment and check for variables in the current Environment all the way back up to the global Environment. Disadvantage of this is that if there are many scopes finding variables can be very slow (not updating though, as any time we set a variable we'd just do env.set_local_fd() as the scopes are only used for subshells). If we do this we'd probably want to write a custom HashMap that allows us to provide the hashed key (so that we don't need to keep hashing the key over and over again when going up the chain of scopes).

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

No branches or pull requests

1 participant