Skip to content

Commit e04cde3

Browse files
committed
fix: Remove check before 'unlink'. Closes #61
The check was originally implemented because it was required for 'abstract-mans' (and copied to the other abstract-*.sh files). This is because the heuristics for the man linking implemented the same search functionality for the root directory and the 'man' subdirectory, which caused files to be detected twice. On the second unlink, a failure occured. Since that code no longer exists, the check is no longer needed
1 parent 9bed4e3 commit e04cde3

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

pkg/lib/util/abstract-bins.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ abstract.bins_do_action() {
127127
fi
128128
;;
129129
unlink)
130-
if [ -f "$BPM_INSTALL_BIN/$binName" ]; then
131-
unlink "$BPM_INSTALL_BIN/$binName"
130+
if ! unlink "$BPM_INSTALL_BIN/$binName"; then
131+
die "Unlink failed, but was expected to succeed"
132132
fi
133133
;;
134134
esac

pkg/lib/util/abstract-completions.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ abstract.completions_do_action_bash() {
142142
fi
143143
;;
144144
unlink)
145-
if [ -f "$BPM_INSTALL_COMPLETIONS/bash/$fileName" ]; then
146-
unlink "$BPM_INSTALL_COMPLETIONS/bash/$fileName"
145+
if ! unlink "$BPM_INSTALL_COMPLETIONS/bash/$fileName"; then
146+
die "Unlink failed, but was expected to succeed"
147147
fi
148148
;;
149149
esac
@@ -165,15 +165,16 @@ abstract.completions_do_action_zsh() {
165165
case "$action" in
166166
link)
167167
if [ -L "$BPM_INSTALL_COMPLETIONS/zsh/compsys/$fileName" ]; then
168+
# TODO: ?
168169
log.error "Skipping '$fileName' since an existing symlink with the same name already exists"
169170
else
170171
mkdir -p "$BPM_INSTALL_COMPLETIONS/zsh/compsys"
171172
ln -sf "$file" "$BPM_INSTALL_COMPLETIONS/zsh/compsys/$fileName"
172173
fi
173174
;;
174175
unlink)
175-
if [ -f "$BPM_INSTALL_COMPLETIONS/zsh/compsys/$fileName" ]; then
176-
unlink "$BPM_INSTALL_COMPLETIONS/zsh/compsys/$fileName"
176+
if ! unlink "$BPM_INSTALL_COMPLETIONS/zsh/compsys/$fileName"; then
177+
die "Unlink failed, but was expected to succeed"
177178
fi
178179
;;
179180
esac
@@ -188,8 +189,8 @@ abstract.completions_do_action_zsh() {
188189
fi
189190
;;
190191
unlink)
191-
if [ -f "$BPM_INSTALL_COMPLETIONS/zsh/compctl/${file##*/}" ]; then
192-
unlink "$BPM_INSTALL_COMPLETIONS/zsh/compctl/${file##*/}"
192+
if ! unlink "$BPM_INSTALL_COMPLETIONS/zsh/compctl/${file##*/}"; then
193+
die "Unlink failed, but was expected to succeed"
193194
fi
194195
;;
195196
esac
@@ -212,8 +213,8 @@ abstract.completions_do_action_fish() {
212213
fi
213214
;;
214215
unlink)
215-
if [ -f "$BPM_INSTALL_COMPLETIONS/fish/${file##*/}" ]; then
216-
unlink "$BPM_INSTALL_COMPLETIONS/fish/${file##*/}"
216+
if ! unlink "$BPM_INSTALL_COMPLETIONS/fish/${file##*/}"; then
217+
die "Unlink failed, but was expected to succeed"
217218
fi
218219
;;
219220
esac

pkg/lib/util/abstract-mans.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,8 @@ abstract.mans_do_action() {
104104
fi
105105
;;
106106
unlink)
107-
# Because 'abstract.mans_search_heuristics' sometimes repeats
108-
# directories, and sometimes the stat's are out of dates, we add this
109-
# check in case a file was deleted in the meantime
110-
if [ -f "$BPM_INSTALL_MAN/man$n/$manFile" ]; then
111-
unlink "$BPM_INSTALL_MAN/man$n/$manFile"
107+
if ! unlink "$BPM_INSTALL_MAN/man$n/$manFile"; then
108+
die "Unlink failed, but was expected to succeed"
112109
fi
113110
;;
114111
esac

0 commit comments

Comments
 (0)