The warning is NOT a bug. The -n
or --no-clobber
really is deprecated with planned removal from cp
in the future. However, their suggested fix with --update=none
has been reported as having bugs.
For this reason, and the fact that --update=none
is NOT backwards compatible (it is not recognized on Ubuntu 22.04, 20.04, 18.04 etc) SlickStack has taken another route:
## ss_cp_if_not_exists (avoids deprecated -n option) ##
function ss_cp_if_not_exists {
command mkdir -p "$(dirname "$2")" && command test ! -e "$2" && command cp "$1" "$2"
}
This approach simply avoids the problems altogether 😉
Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-functions.txt
Because if you try to use --update=none
on those older Ubuntu versions, well it will fail and you will see this error:
cp: option ‘–update’ doesn’t allow an argument
Try ‘cp –help’ for more information.