From 4c8d40bbadc85e01c557327ccc2d21705ad4ef2a Mon Sep 17 00:00:00 2001 From: ale5000 <15793015+ale5000-git@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:50:20 +0200 Subject: [PATCH] Update bits-info.sh --- tools/bits-info.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tools/bits-info.sh b/tools/bits-info.sh index 8706b500..8931bc08 100755 --- a/tools/bits-info.sh +++ b/tools/bits-info.sh @@ -335,19 +335,25 @@ main() fi echo '===' - readlink 2> /dev/null "/proc/${$}/exe"; printf '\n$?' +readlink 2> /dev/null "/proc/${$}/exe" || true; printf "\n" +if shell_exe="$(readlink 2> /dev/null "/proc/${$}/exe")"; then + echo "${shell_exe:?}" # +fi echo '---' - tmp_var="$(ps 2> /dev/null -p "${$}" -o 'comm=')" && test -n "${tmp_var?}" && tmp_var2="$(command 2> /dev/null -v "${tmp_var:?}")"; echo $? - echo "$tmp_var" - echo "$tmp_var2" - readlink "$tmp_var2" - readlink -f "$tmp_var2" - realpath "$tmp_var2" +ps 2> /dev/null -p "${$}" -o 'comm=' +if tmp_var="$(ps 2> /dev/null -p "${$}" -o 'comm=')" && test -n "${tmp_var?}" && tmp_var="$(command 2> /dev/null -v "${tmp_var:?}")"; then + # On Linux / macOS + shell_exe="$(readlink 2> /dev/null -f "${tmp_var:?}" || realpath 2> /dev/null "${tmp_var:?}" || "${tmp_var:?}")" + echo "${shell_exe:?}" # +fi echo '---' - echo "${BASH:-${SHELL-}}" - command -v "${BASH:-${SHELL-}}"; echo $? +echo "${BASH:-${SHELL-}}" +if tmp_var="${BASH:-${SHELL-}}" && test -n "${tmp_var?}" && tmp_var="$(command 2> /dev/null -v "${tmp_var:?}")"; then + echo "${tmp_var:?}" # + shell_exe="$(readlink 2> /dev/null -f "${tmp_var:?}" || realpath 2> /dev/null "${tmp_var:?}" || "${tmp_var:?}")" + echo "${shell_exe:?}" # +fi echo '===' - shell_info="$(get_shell_info || true)" shell_name="$(printf '%s\n' "${shell_info:?}" | cut -d ' ' -f '1' || true)"