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 (naive) exec builtin command #36

Merged
merged 3 commits into from Dec 15, 2021
Merged

Conversation

KeenS
Copy link
Contributor

@KeenS KeenS commented Dec 6, 2021

This P-R partially implements exec command. It only supports exec cat maggie syntax and doesn't exec 3< readfile.

See also https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#exec

Copy link
Owner

@nuta nuta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR, @KeenS! Generally looks good to me. Can you take a look at some nitpicks from me.

};

match nix::unistd::execvp(&command, &args) {
Ok(never) => match never {},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe we can assume execvp won't return a success value.

Suggested change
Ok(never) => match never {},
Ok(_) => unreachable!(),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. Because so, I'm matching against Infallible, which is stronger assertion than ignoring value and calling unreachable .

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds better! I have never heard of never. Thank you for explanation 😃

src/builtins/exec.rs Outdated Show resolved Hide resolved
src/builtins/exec.rs Outdated Show resolved Hide resolved
KeenS and others added 2 commits December 14, 2021 11:03
Co-authored-by: Seiya Nuta <nuta@seiya.me>
Co-authored-by: Seiya Nuta <nuta@seiya.me>
@nuta nuta merged commit 4e90833 into nuta:main Dec 15, 2021
@nuta
Copy link
Owner

nuta commented Dec 15, 2021

Thank you again @KeenS!

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

Successfully merging this pull request may close these issues.

None yet

2 participants