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

RFC: Recursive cp #10448

Merged
merged 1 commit into from Mar 10, 2015
Merged

RFC: Recursive cp #10448

merged 1 commit into from Mar 10, 2015

Conversation

ghost
Copy link

@ghost ghost commented Mar 8, 2015

Addresses #10434, went with keyword argument as proposed by @simonster to be in line with rm. Tests included.

Late-night recreational coding, second opinions appreciated.

for p in readdir(src)
cp(joinpath(src, p), joinpath(dst, p), recursive=recursive)
end
end
Copy link
Member

Choose a reason for hiding this comment

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

We should probably have an else here that throws an error if the user tries to copy a directory without recursive.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, should we create a new error for this? Python throws IsADirectoryError.

@ivarne
Copy link
Member

ivarne commented Mar 9, 2015

ArgumentError seems appropriate enough. We don't yet have detailed exception hierarchies in Julia.

We should also have a suggestion to use the recursive flag in the error message. Otherwise we'll get bug reports that cp can't copy directories, which is a waste of our users time (and our own when we have to answer ).

@ghost
Copy link
Author

ghost commented Mar 9, 2015

Pushed new version that raises ArgumentError when copying directories without recursive.

end
else
throw(ArgumentError(string("'$src' is a directory. ",
"To copy, set the `recursive` keyword argument to true.")))
Copy link
Member

Choose a reason for hiding this comment

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

How about

'$src' is a directory.
Use `cp(src, dst, recursive=true)` to copy directories recursively.

I don't like to rely on users understanding terminology.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, updating and pushing.

@ghost
Copy link
Author

ghost commented Mar 9, 2015

Travis Linux i686 failure appears unrelated, OS X timed out. All others passed.

@ghost
Copy link
Author

ghost commented Mar 10, 2015

OS X timed out again.

tkelman added a commit that referenced this pull request Mar 10, 2015
@tkelman tkelman merged commit 493d444 into JuliaLang:master Mar 10, 2015
@tkelman
Copy link
Contributor

tkelman commented Mar 10, 2015

Good to see another PR from you @ninjin!

@ghost
Copy link
Author

ghost commented Mar 10, 2015

@tkelman: I am recovering, hopefully I can take a stab at extending the Travis integration shortly.

@ghost ghost deleted the nin/cpr branch March 10, 2015 13:17
@tkelman
Copy link
Contributor

tkelman commented Mar 11, 2015

this is probably worth mentioning in the docs, huh

ivarne added a commit that referenced this pull request Mar 11, 2015
@ivarne
Copy link
Member

ivarne commented Mar 11, 2015

Docs in 45e5fa1

@tkelman
Copy link
Contributor

tkelman commented Mar 11, 2015

thanks @ivarne

@peter1000 peter1000 mentioned this pull request Apr 19, 2015
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.

3 participants