Skip to content

Commit f572dba

Browse files
devstuffmislav
andauthored
Canonicalize symlinked paths to rbenv executable (#49)
Co-authored-by: Mislav Marohnić <git@mislav.net>
1 parent 826acc5 commit f572dba

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

bin/rbenv-doctor

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ command-list() {
1414
which -a "$1"
1515
}
1616

17-
indent() {
18-
sed 's/^/ /'
17+
deduplicate-paths() {
18+
local path
19+
while read -r path; do
20+
readlink -f "$path" || printf "%s\n" "$path"
21+
done | uniq
1922
}
2023

21-
# for ubuntu /bin is a symlink to /usr/bin
22-
# which -a doesn't know the binaries are the same
23-
fix-usr-bin() {
24-
sed 's:^/usr/bin/:/bin/:'
24+
indent() {
25+
sed 's/^/ /'
2526
}
2627

2728
printc() {
@@ -55,7 +56,7 @@ fi
5556
warnings=0
5657

5758
echo -n "Checking for \`rbenv' in PATH: "
58-
num_locations="$(command-list rbenv | fix-usr-bin | uniq | count-lines)"
59+
num_locations="$(command-list rbenv | deduplicate-paths | count-lines)"
5960
if [ "$num_locations" -eq 0 ]; then
6061
printc red "not found"
6162
echo
@@ -123,7 +124,7 @@ fi
123124
echo -n "Checking \`rbenv install' support: "
124125
rbenv_installs="$({ ls "$RBENV_ROOT"/plugins/*/bin/rbenv-install 2>/dev/null || true
125126
command-list rbenv-install 2>/dev/null || true
126-
} | uniq)"
127+
} | deduplicate-paths)"
127128
num_installs="$(count-lines <<<"$rbenv_installs")"
128129
if [ -z "$rbenv_installs" ]; then
129130
printc red "not found"

0 commit comments

Comments
 (0)