Merge pull request #752 from 4nd3r/__link_messaging

__link: add messaging
This commit is contained in:
Darko Poljak 2019-04-11 13:42:53 +02:00 committed by GitHub
commit e37d955845
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -48,21 +48,25 @@ case "$state_should" in
if [ "$file_type" = "directory" ]; then if [ "$file_type" = "directory" ]; then
# our destination is currently a directory, delete it # our destination is currently a directory, delete it
printf 'rm -rf "%s" &&\n' "$destination" printf 'rm -rf "%s" &&\n' "$destination"
echo "removed '$destination' (directory)" >> "$__messages_out"
else else
if [ "$state_is" = "wrongsource" ]; then if [ "$state_is" = "wrongsource" ]; then
# our destination is a symlink but points to the wrong source, # our destination is a symlink but points to the wrong source,
# delete it # delete it
printf 'rm -f "%s" &&\n' "$destination" printf 'rm -f "%s" &&\n' "$destination"
echo "removed '$destination' (wrongsource)" >> "$__messages_out"
fi fi
fi fi
# create our link # create our link
printf 'ln %s -f "%s" "%s"\n' "$lnopt" "$source" "$destination" printf 'ln %s -f "%s" "%s"\n' "$lnopt" "$source" "$destination"
echo "created '$destination'" >> "$__messages_out"
;; ;;
absent) absent)
# only delete if it is a sym/hard link # only delete if it is a sym/hard link
if [ "$file_type" = "symlink" ] || [ "$file_type" = "hardlink" ]; then if [ "$file_type" = "symlink" ] || [ "$file_type" = "hardlink" ]; then
printf 'rm -f "%s"\n' "$destination" printf 'rm -f "%s"\n' "$destination"
echo "removed '$destination'" >> "$__messages_out"
fi fi
;; ;;
*) *)

View file

@ -27,6 +27,22 @@ state
'present' or 'absent', defaults to 'present' 'present' or 'absent', defaults to 'present'
MESSAGES
--------
created <destination>
Link to destination was created.
removed <destination>
Link to destination was removed.
removed <destination> (directory)
Destination was removed because state is ``present`` and destination was directory.
removed <destination> (wrongsource)
Destination was removed because state is ``present`` and destination link source was wrong.
EXAMPLES EXAMPLES
-------- --------