Skip to content

Commit 0a8d3cd

Browse files
committed
Add warning for broken symlinks
1 parent 50f81e4 commit 0a8d3cd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ Options:
209209
Info provided per symlink:
210210
- target, recursively
211211
- (if relative: canonical path)
212+
- (if broken: warning)
212213
213214
Exit Status:
214215
3 - Invalid options

‎src/symlink-info.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Options:
1919
Info provided per symlink:
2020
- target, recursively
2121
- (if relative: canonical path)
22+
- (if broken: warning)
2223
2324
Exit Status:
2425
3 - Invalid options
@@ -58,7 +59,7 @@ while getopts :hv OPT; do
5859
exit 0
5960
;;
6061
v)
61-
echo "symlink-info 0.2.2"
62+
echo "symlink-info 0.3.0"
6263
exit 0
6364
;;
6465
*)
@@ -111,6 +112,13 @@ for path; do
111112
_indent 1
112113
printf 'canonical path: %s\n' "$path_canonical"
113114
fi
115+
116+
if [[ ! -e $path_canonical ]]; then
117+
printf >&2 "%s: Warning: Broken symlink. Target does not exist: %s\n" \
118+
"$basename" \
119+
"$path_canonical"
120+
exit=1
121+
fi
114122
done
115123

116124
exit $exit

0 commit comments

Comments
 (0)