__link: add messaging
This commit is contained in:
		
					parent
					
						
							
								13671c666c
							
						
					
				
			
			
				commit
				
					
						204a572709
					
				
			
		
					 2 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
					@ -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
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    *)
 | 
					    *)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
--------
 | 
					--------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue