Skip to content

Commit

Permalink
file.jl: add a note differentiating cp function from cp command (J…
Browse files Browse the repository at this point in the history
…uliaLang#41761)

The `cp` function behaves more deterministically than the command and
can have serious consequences if `force=true` when `dst` is a directory.
Add a note to the docstring mentioning this.
  • Loading branch information
thazhemadam authored and LilithHafner committed Mar 8, 2022
1 parent 5fc5804 commit 75b989f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ If `follow_symlinks=false`, and `src` is a symbolic link, `dst` will be created
symbolic link. If `follow_symlinks=true` and `src` is a symbolic link, `dst` will be a copy
of the file or directory `src` refers to.
Return `dst`.
!!! note
The `cp` function is different from the `cp` command. The `cp` function always operates on
the assumption that `dst` is a file, while the command does different things depending
on whether `dst` is a directory or a file.
Using `force=true` when `dst` is a directory will result in loss of all the contents present
in the `dst` directory, and `dst` will become a file that has the contents of `src` instead.
"""
function cp(src::AbstractString, dst::AbstractString; force::Bool=false,
follow_symlinks::Bool=false)
Expand Down

0 comments on commit 75b989f

Please sign in to comment.