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

Minimum redirection semantics #86

Merged
merged 13 commits into from
Sep 23, 2021
Merged

Minimum redirection semantics #86

merged 13 commits into from
Sep 23, 2021

Conversation

magicant
Copy link
Owner

@magicant magicant commented Sep 20, 2021

This pull request implements the < redirection for external utility in simple command.

  • Expand filename
  • Open file
  • Handle file opening error
  • Move FD
  • Call redirection function in simple command

  • System::open
  • Wrap SimpleCommand::redirs in Rc
    • Needed to perform redirections in a subshell

Redirections performed in a subshell should be shared in an Rc so that
the subshell can access the redirections asynchronously without creating
a clone.
The following snippet does not compile because of conflicting borrows.
To work out, RedirEnv should be created by the caller of the perform
function, rather than being returned from the function.

let mut env = match redir::perform(env, &redirs).await {
    Ok(env) => env,
    Err(_) => return drop(e.handle(env).await),
};
in favor of RedirEnv::perform_redir
for better documentation rendering
@magicant magicant marked this pull request as ready for review September 23, 2021 14:44
@magicant magicant merged commit 853b88c into master Sep 23, 2021
@magicant magicant deleted the redir branch September 23, 2021 15:11
@magicant magicant mentioned this pull request Sep 23, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant