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

access Cmd elements as an array of strings #21197

Merged
merged 2 commits into from
May 19, 2017

Conversation

stevengj
Copy link
Member

Currently, a Cmd is a rather opaque object: there is no way to "look inside" it without accessing undocumented fields of the Cmd object. I ran into this recently when I wanted a function of a Cmd to do something different depending on the program being executed.

As a first step, this PR allows you to iterate and index a Cmd object as if it were an array of strings, e.g.:

julia> collect(`echo "foo bar"`)
2-element Array{String,1}:
 "echo"   
 "foo bar"

julia> `echo "foo bar"`[2]
"foo bar"

(This is just a thin wrapper around cmd.exec.)

Copy link
Member

@StefanKarpinski StefanKarpinski left a comment

Choose a reason for hiding this comment

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

LGTM. I've considered doing this a number of times.

@tkelman
Copy link
Contributor

tkelman commented Mar 28, 2017

Useful, but we are in feature freeze.

@StefanKarpinski
Copy link
Member

Sure. We should probably branch after beta so that we can start merging features. The 1.0 release cycle will be very short already.

@tkelman
Copy link
Contributor

tkelman commented Mar 28, 2017

Depends at what point waiting to merge features becomes more trouble than backporting all bugfixes. We have enough bugfixes continuing that I don't think we're there yet.

@StefanKarpinski
Copy link
Member

We can also make bug fixes on the release branch and merged them forward to master.

@stevengj
Copy link
Member Author

stevengj commented May 2, 2017

Now that there is a release-0.6 branch, can this be merged into master?

@stevengj
Copy link
Member Author

stevengj commented May 8, 2017

merge?

@StefanKarpinski StefanKarpinski merged commit 73b8dcb into JuliaLang:master May 19, 2017
@stevengj stevengj deleted the cmdarray branch June 13, 2017 11:14
stevengj added a commit to JuliaLang/Compat.jl that referenced this pull request Jul 14, 2017
tkelman pushed a commit to JuliaLang/Compat.jl that referenced this pull request Jul 20, 2017
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.

4 participants