Skip to content

Commit a2babd2

Browse files
lijinliangyihaojinliang.li
authored andcommitted
specifically handle a broken symlink
1 parent 47f7eb2 commit a2babd2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bin/as.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ rreadlink() ( # Execute the function in a *subshell* to localize variables and t
4545
{ \unalias command; \unset -f command; } >/dev/null 2>&1
4646
[ -n "$ZSH_VERSION" ] && options[POSIX_BUILTINS]=on # make zsh find *builtins* with `command` too.
4747

48+
if [[ `command file $target` =~ broken ]]; then
49+
echo 'Error:' `file $target`
50+
return 1
51+
fi
52+
4853
while :; do # Resolve potential symlinks until the ultimate target is found.
4954
[ -L "$target" ] || [ -e "$target" ] || { command printf '%s\n' "ERROR: '$target' does not exist." >&2; return 1; }
5055
command cd "$(command dirname -- "$target")" # Change to target dir; necessary for correct resolution of target path.

0 commit comments

Comments
 (0)