3 # Try to hardlink a file into a directory, fallback to copy on failure.
5 # Hardlink-or-copy the source file in the first argument into the
6 # destination directory in the second argument, using the basename in
7 # the third argument as basename for the destination file. If the third
8 # argument is missing, use the basename of the source file as basename
9 # for the destination file.
11 # In either case, remove the destination prior to doing the
14 # Note that this is NOT an atomic operation.
23 if [ -n "${dst_file}" ]; then
24 dst_file
="${dst_dir}/${dst_file}"
26 dst_file
="${dst_dir}/${src_file##*/}"
31 ln -f "${src_file}" "${dst_file}" 2>/dev
/null \
32 ||
cp -f "${src_file}" "${dst_file}"