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

Improve redirections #42

Merged
merged 7 commits into from
Feb 3, 2017
Merged

Improve redirections #42

merged 7 commits into from
Feb 3, 2017

Conversation

smondet
Copy link
Member

@smondet smondet commented Feb 2, 2017

See issue #41 for some explanations of “how” and #40 for the “why.”

This fixes issue #40 by avoiding the serialization of the `unit t`
expression being acted upon.

On the example of the issue #40 is reduces the size from 500 KiB to less
than 100 KiB.
It changes the semantics of `EDSL.with_redirections` to be the one of
the shell's `exec` built-in.
@smondet smondet self-assigned this Feb 2, 2017
@smondet smondet requested review from rleonid and removed request for rleonid February 2, 2017 22:46
@smondet smondet added WIP and removed WIP labels Feb 3, 2017
@smondet smondet requested a review from ihodes February 3, 2017 18:10
Copy link
Member

@ihodes ihodes left a comment

Choose a reason for hiding this comment

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

Looks cool, couple comments/Qs!

src/lib/EDSL.mli Outdated
- then, ["printf"] outputs to [1].

Invalid cases, like redirecting to a file-descriptor has not been
openned, lead to undefined behavior; see
Copy link
Member

Choose a reason for hiding this comment

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

opened*

src/test/main.ml Outdated
write_output
~return_value:tmp2#path (
with_redirections (exec ["printf"; "%s"; recognizable]) [
to_fd (int 4) (int 3);
Copy link
Member

Choose a reason for hiding this comment

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

is this doing anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

This redirection is the one that fails, since fd 3 is not yet opened.

In the POSIX case, with_redirections then exits, in the bash/zsh case it keeps going.

Copy link
Member

Choose a reason for hiding this comment

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

gotcha, now i understand what's going on 🙏

assert_or_fail "fd3" (
(tmp1#get =$= string "")
|||
(this_is_bash
Copy link
Member

Choose a reason for hiding this comment

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

why would we expect the file to have the string in it in bash? (and why only bash?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Bash does not exit on failed exec calls.
Cf. #41
(and the doc-comments of EDSL.with_redirections)

@smondet smondet merged commit 60f8d05 into master Feb 3, 2017
smondet added a commit that referenced this pull request Feb 3, 2017
@smondet smondet deleted the improve-redirections branch July 12, 2018 18:37
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.

2 participants