2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-26 13:30:30 +00:00

clean rm of copied dirs and files (#799)

This commit is contained in:
Joy Gao 2024-03-27 04:02:47 -10:00 committed by Greg Magolan
parent b4b7d1bc1c
commit 59ca59cfc1
No known key found for this signature in database
GPG key ID: 3ED3220F08EA5070

View file

@ -209,6 +209,8 @@ out={out_path}
mkdir -p "$(dirname "$out")"
if [[ -f "$in" ]]; then
echo "Copying file $in to $out in $PWD"
# in case `cp` from previous command was terminated midway which can result in read-only files/dirs
chmod -R ug+w "$out" > /dev/null 2>&1 || true
rm -Rf "$out"
cp -f "$in" "$out"
# cp should make the file writable but call chmod anyway as a defense in depth
@ -217,6 +219,8 @@ if [[ -f "$in" ]]; then
{executable_file}
else
echo "Copying directory $in to $out in $PWD"
# in case `cp` from previous command was terminated midway which can result in read-only files/dirs
chmod -R ug+w "$out" > /dev/null 2>&1 || true
rm -Rf "$out"/*
mkdir -p "$out"
cp -fRL "$in"/* "$out"