Skip to content

Commit

Permalink
Merge branch 'micro5k:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git authored Nov 2, 2024
2 parents 629790e + 05b7eed commit 8de84b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions cmdline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ command 1> /dev/null 2>&1 -v 'local' || {
if test "${A5K_FUNCTIONS_INCLUDED:-false}" = 'false'; then
main()
{
local _main_dir _run_strategy _applet _nl
local _main_dir _run_strategy _applet _uname_os _nl

# Execute only if the first initialization has not already been done
if test -z "${MAIN_DIR-}" || test -z "${USER_HOME-}"; then

# Avoid picturesque bugs on Bash under Windows
if test -x '/usr/bin/uname' && test "$(/usr/bin/uname 2> /dev/null -o || :)" = 'Msys'; then PATH="/usr/bin:${PATH:-%empty}"; fi
if test -x '/usr/bin/uname' && _uname_os="$(/usr/bin/uname 2> /dev/null -o)" && test "${_uname_os}" = 'Msys'; then PATH="/usr/bin:${PATH:-%empty}"; fi

if test -z "${MAIN_DIR-}"; then
# shellcheck disable=SC3028,SC2128 # Intended: In POSIX sh, BASH_SOURCE is undefined / Expanding an array without an index only gives the first element
Expand Down Expand Up @@ -51,10 +51,10 @@ if test "${A5K_FUNCTIONS_INCLUDED:-false}" = 'false'; then
elif _gse_tmp_var="$(ps 2> /dev/null -p "${$}" -o 'comm=')" && test -n "${_gse_tmp_var}" && _gse_tmp_var="$(command 2> /dev/null -v "${_gse_tmp_var}")"; then
# On Linux / macOS
# shellcheck disable=SC2230 # Ignore: 'which' is non-standard
case "${_gse_tmp_var}" in *'/'* | *"\\"*) ;; *) _gse_tmp_var="$(which 2> /dev/null "${_gse_tmp_var}")" || return 3 ;; esac # We may not get the full path with "command -v" on osh
case "${_gse_tmp_var}" in *'/'* | *"\\"*) ;; *) _gse_tmp_var="$(which 2> /dev/null "${_gse_tmp_var}")" || return 3 ;; esac # We may not get the full path with "command -v" on some old versions of Oils
elif _gse_tmp_var="${BASH:-${SHELL-}}" && test -n "${_gse_tmp_var}"; then
if test "${_gse_tmp_var}" = '/bin/sh' && test "$(uname 2> /dev/null || :)" = 'Windows_NT'; then _gse_tmp_var="$(command 2> /dev/null -v 'busybox')" || return 2; fi
if test ! -e "${_gse_tmp_var}" && test -e "${_gse_tmp_var}.exe"; then _gse_tmp_var="${_gse_tmp_var}.exe"; fi # Special fix for broken versions of Bash under Windows
if test ! -x "${_gse_tmp_var}" && test -x "${_gse_tmp_var}.exe"; then _gse_tmp_var="${_gse_tmp_var}.exe"; fi # Special fix for broken versions of Bash under Windows
else
return 1
fi
Expand Down
42 changes: 21 additions & 21 deletions tools/bits-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# shellcheck disable=SC3043 # In POSIX sh, local is undefined

SCRIPT_NAME='Bits info'
SCRIPT_VERSION='1.5.20'
SCRIPT_VERSION='1.5.21'

### CONFIGURATION ###

Expand Down Expand Up @@ -652,7 +652,7 @@ get_shell_exe()
elif _gse_tmp_var="$(ps 2> /dev/null -p "${$}" -o 'comm=')" && test -n "${_gse_tmp_var}" && _gse_tmp_var="$(command 2> /dev/null -v "${_gse_tmp_var}")"; then
# On Linux / macOS
# shellcheck disable=SC2230 # Ignore: 'which' is non-standard
case "${_gse_tmp_var}" in *'/'* | *"\\"*) ;; *) _gse_tmp_var="$(which 2> /dev/null "${_gse_tmp_var}")" || return 3 ;; esac # We may not get the full path with "command -v" on some versions of Oils
case "${_gse_tmp_var}" in *'/'* | *"\\"*) ;; *) _gse_tmp_var="$(which 2> /dev/null "${_gse_tmp_var}")" || return 3 ;; esac # We may not get the full path with "command -v" on some old versions of Oils
elif _gse_tmp_var="${BASH:-${SHELL-}}" && test -n "${_gse_tmp_var}"; then
if test "${_gse_tmp_var}" = '/bin/sh' && test "$(uname 2> /dev/null || :)" = 'Windows_NT'; then _gse_tmp_var="$(command 2> /dev/null -v 'busybox')" || return 2; fi
if test ! -x "${_gse_tmp_var}" && test -x "${_gse_tmp_var}.exe"; then _gse_tmp_var="${_gse_tmp_var}.exe"; fi # Special fix for broken versions of Bash under Windows
Expand Down Expand Up @@ -796,41 +796,41 @@ get_applet_name()
_gan_backup_ifs="${IFS-unset}"
IFS="${_gan_sep}"
# shellcheck disable=SC2086 # Ignore: Double quote to prevent globbing and word splitting
set -- ${_shell_cmdline} || set --
set -- ${_shell_cmdline} || set -- || return 126
if test "${_gan_backup_ifs}" = 'unset'; then unset IFS; else IFS="${_gan_backup_ifs}"; fi
elif _shell_cmdline="$(ps 2> /dev/null -p "${$}" -o 'args=')" && test -n "${_shell_cmdline}"; then
set -- "${_shell_cmdline}" || set --
set -- "${_shell_cmdline}" || set -- || return 126
else
printf '%s\n' 'failed'
return 3
set -- || return 126
fi

# We cover two cases:
# - /bin/busybox ash
# - /bin/ash

for _gan_applet in bash lash msh hush ash osh ysh sh; do
if test "${2:-empty}" = "${_gan_applet}"; then
: # Found
else
case "${1:-empty}" in
*"/${_gan_applet}"* | *" ${_gan_applet}"*) ;; # Found
*) continue ;; # Not found yet
esac
fi
if test "${#}" -gt 0; then
for _gan_applet in bash lash msh hush ash osh ysh oil sh; do
if test "${2:-empty}" = "${_gan_applet}"; then
: # Found
else
case "${1:-empty}" in
*"/${_gan_applet}"* | *" ${_gan_applet}"*) ;; # Found
*) continue ;; # Not found yet
esac
fi

printf '%s\n' "${_gan_applet}"
return 0
done
printf '%s\n' "${_gan_applet}"
return 0
done
fi
;;
*)
printf '%s\n' 'not-an-applet'
return 1
return 2 # NOT an applet
;;
esac

printf '%s\n' 'unknown'
return 2
return 0
}

retrieve_bitness_from_uname()
Expand Down

0 comments on commit 8de84b6

Please sign in to comment.