From ee3a8cc15703f8e9fb6a38dbcf494d7c720ec06f Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam Date: Tue, 3 Aug 2021 00:07:32 +0530 Subject: [PATCH] file.jl: add a note differentiating `cp` function from `cp` command 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 --- base/file.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base/file.jl b/base/file.jl index f9deb5b9fbe48..85450ff2d3645 100644 --- a/base/file.jl +++ b/base/file.jl @@ -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)