Skip to content

Commit

Permalink
file.jl: add a note differentiating cp function from cp command
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
  • Loading branch information
thazhemadam committed Aug 2, 2021
1 parent bdacfa2 commit 0416dc7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ 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 0416dc7

Please sign in to comment.