diff --git a/README.md b/README.md index e712d99..1a55978 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ Options: Info provided per symlink: - target, recursively - (if relative: canonical path) + - (if broken: warning) Exit Status: 3 - Invalid options diff --git a/src/symlink-info.sh b/src/symlink-info.sh index 28b7535..004d90f 100755 --- a/src/symlink-info.sh +++ b/src/symlink-info.sh @@ -19,6 +19,7 @@ Options: Info provided per symlink: - target, recursively - (if relative: canonical path) + - (if broken: warning) Exit Status: 3 - Invalid options @@ -58,7 +59,7 @@ while getopts :hv OPT; do exit 0 ;; v) - echo "symlink-info 0.2.2" + echo "symlink-info 0.3.0" exit 0 ;; *) @@ -111,6 +112,13 @@ for path; do _indent 1 printf 'canonical path: %s\n' "$path_canonical" fi + + if [[ ! -e $path_canonical ]]; then + printf >&2 "%s: Warning: Broken symlink. Target does not exist: %s\n" \ + "$basename" \ + "$path_canonical" + exit=1 + fi done exit $exit