files: avoid surprises when linking files (#3018)

This commit is contained in:
Naïm Favier 2023-01-09 13:00:21 +01:00 committed by GitHub
parent 4f0c1afba7
commit 69806e9378
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -185,8 +185,9 @@ in
$VERBOSE_ECHO "Skipping '$targetPath' as it is identical to '$sourcePath'" $VERBOSE_ECHO "Skipping '$targetPath' as it is identical to '$sourcePath'"
else else
# Place that symlink, --force # Place that symlink, --force
# This can still fail if the target is a directory, in which case we bail out.
$DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")"
$DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$sourcePath" "$targetPath" || exit 1
fi fi
done done
''; '';