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

Is there function to execute a shell command #136

Open
jieyuan-shen opened this issue Oct 8, 2015 · 6 comments
Open

Is there function to execute a shell command #136

jieyuan-shen opened this issue Oct 8, 2015 · 6 comments

Comments

@jieyuan-shen
Copy link

As a shell script, is there a function to execute a shell command (e.g. "ls", "pwd", etc.), already?

@matz
Copy link
Owner

matz commented Oct 8, 2015

Sorry, not yet.

@mattn
Copy link
Contributor

mattn commented Oct 8, 2015

it's easy to implement with popen, i guess.

@amiralles
Copy link

Hey @matz! Big fan of your work!

Would the syntax for this feature look something like this?

system('ls') { in, out, err -> ... } | stdout

If so, I could try to implement it. Thanks!

@matz
Copy link
Owner

matz commented Nov 12, 2018

What I thought was:

spawn("ls") | stdout                           # can be a producer
stream | spawn("grep foo") | stdout  # and also be a filter
stream | spawn("cat > /tmp/a")         # and a consumer

@amiralles
Copy link

amiralles commented Nov 12, 2018 via email

@amiralles
Copy link

I managed to implement the first use-case on my fork (and it seems to work fine so far)

spawn("ls") | stdout    # can be a producer

Now I'm stuck at this one:

stream | spawn("grep foo") | stdout  # and also be a filter

As far as I understand, a stream can be a producer, a consumer, or a filter, but not all at the same time. So, the first question is:

Is it possible for the spawn function to produce different kinds of streams based on their usage?

If so, is there a way to identify how the function is being used (maybe based on the stream parameter or something like that)?

Thanks!

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

4 participants