From 4f6510daf1bb57c5ab9b6e07ff4fc5bfff6546da Mon Sep 17 00:00:00 2001 From: bol-van Date: Sat, 3 Jan 2026 00:39:29 +0300 Subject: [PATCH] base.sh: detect hard links to busybox --- common/base.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/common/base.sh b/common/base.sh index 83d9d8c..3e6891a 100644 --- a/common/base.sh +++ b/common/base.sh @@ -172,15 +172,24 @@ unique() is_linked_to_busybox() { - local IFS F P - + local IFS F P BB + + BB="$(which busybox)" + IFS=: for path in $PATH; do - F=$path/$1 - P="$(readlink $F)" - if [ -z "$P" ] && [ -x $F ] && [ ! -L $F ]; then return 1; fi - [ "${P%busybox*}" != "$P" ] && return + F="$path/$1" + if [ -L "$F" ]; then + P="$(readlink $F)" + if [ -z "$P" ] && [ -x $F ] && [ ! -L $F ]; then return 1; fi + [ "${P%busybox*}" != "$P" ] && return + elif [ -f "$F" -a -n "$BB" ]; then + # possible hardlink + [ $(get_dir_inode "$F") = $(get_dir_inode "$BB") ] + return + fi done + return 1 } get_dir_inode() {