Resolve SC2012.
This commit is contained in:
		
					parent
					
						
							
								ec186673bf
							
						
					
				
			
			
				commit
				
					
						0458f66c96
					
				
			
		
					 2 changed files with 25 additions and 20 deletions
				
			
		|  | @ -33,8 +33,7 @@ destination_dir="${destination%/*}" | ||||||
| case "$type" in | case "$type" in | ||||||
|    symbolic) |    symbolic) | ||||||
|       cd "$destination_dir" || exit 1 |       cd "$destination_dir" || exit 1 | ||||||
|       # TODO SC2012: use readlink or something? |       source_is=$(readlink "$destination") | ||||||
|       source_is=$(ls -l "$destination" | sed 's/.*-> //g') |  | ||||||
|       if [ -h "$destination" ]; then |       if [ -h "$destination" ]; then | ||||||
|          # ignore trailing slashes for comparison |          # ignore trailing slashes for comparison | ||||||
|          if [ "${source_is%/}" = "${source%/}" ]; then |          if [ "${source_is%/}" = "${source%/}" ]; then | ||||||
|  | @ -53,9 +52,13 @@ case "$type" in | ||||||
|          echo sourcemissing |          echo sourcemissing | ||||||
|          exit 0 |          exit 0 | ||||||
|       fi |       fi | ||||||
|       # TODO SC2012: use stat? |       # Currently not worth the effor to change it, stat is not defined by POSIX | ||||||
|  |       # and different OSes has different implementations for it. | ||||||
|  |       # shellcheck disable=SC2012 | ||||||
|       destination_inode=$(ls -i "$destination" | awk '{print $1}') |       destination_inode=$(ls -i "$destination" | awk '{print $1}') | ||||||
|       # TODO SC2012: use stat? |       # Currently not worth the effor to change it, stat is not defined by POSIX | ||||||
|  |       # and different OSes has different implementations for it. | ||||||
|  |       # shellcheck disable=SC2012 | ||||||
|       source_inode=$(ls -i "$source" | awk '{print $1}') |       source_inode=$(ls -i "$source" | awk '{print $1}') | ||||||
|       if [ "$destination_inode" -eq "$source_inode" ]; then |       if [ "$destination_inode" -eq "$source_inode" ]; then | ||||||
|          echo present |          echo present | ||||||
|  |  | ||||||
|  | @ -24,24 +24,26 @@ | ||||||
| destination="/$__object_id" | destination="/$__object_id" | ||||||
| 
 | 
 | ||||||
| if [ ! -e "$destination" ]; then | if [ ! -e "$destination" ]; then | ||||||
|    echo none |     echo none | ||||||
| elif [ -h "$destination" ]; then | elif [ -h "$destination" ]; then | ||||||
|    echo symlink |     echo symlink | ||||||
| elif [ -f "$destination" ]; then | elif [ -f "$destination" ]; then | ||||||
|    type="$(cat "$__object/parameter/type")" |     type="$(cat "$__object/parameter/type")" | ||||||
|    case "$type" in |     case "$type" in | ||||||
|       hard) |         hard) | ||||||
|          # TODO SC2012: use stat? |             # Currently not worth the effor to change it, stat is not defined by POSIX | ||||||
|          link_count=$(ls -l "$destination" | awk '{ print $2 }') |             # and different OSes has different implementations for it. | ||||||
|          if [ "$link_count" -gt 1 ]; then |             # shellcheck disable=SC2012 | ||||||
|             echo hardlink |             ink_count=$(ls -l "$destination" | awk '{ print $2 }') | ||||||
|             exit 0 |             if [ "$link_count" -gt 1 ]; then | ||||||
|          fi |                 echo hardlink | ||||||
|       ;; |                 exit 0 | ||||||
|    esac |             fi | ||||||
|    echo file |         ;; | ||||||
|  |     esac | ||||||
|  |     echo file | ||||||
| elif [ -d "$destination" ]; then | elif [ -d "$destination" ]; then | ||||||
|    echo directory |     echo directory | ||||||
| else | else | ||||||
|    echo unknown |     echo unknown | ||||||
| fi | fi | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue