Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git committed Oct 7, 2024
1 parent 40195fc commit 355e407
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
18 changes: 9 additions & 9 deletions cmdline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if test "${A5K_FUNCTIONS_INCLUDED:-false}" = 'false'; then

if test -z "${MAIN_DIR-}"; then
# shellcheck disable=SC3028 # Ignore: In POSIX sh, BASH_SOURCE is undefined.
if test -n "${BASH_SOURCE-}" && MAIN_DIR="$(dirname "${BASH_SOURCE:?}")" && MAIN_DIR="$(realpath "${MAIN_DIR:?}")"; then
if test -n "${BASH_SOURCE-}" && MAIN_DIR="$(dirname "${BASH_SOURCE}")" && MAIN_DIR="$(realpath "${MAIN_DIR}")"; then
export MAIN_DIR
else
unset MAIN_DIR
Expand All @@ -30,7 +30,7 @@ if test "${A5K_FUNCTIONS_INCLUDED:-false}" = 'false'; then
if test -n "${MAIN_DIR-}" && test -z "${USER_HOME-}"; then
if test "${TERM_PROGRAM-}" = 'mintty'; then unset TERM_PROGRAM; fi
export USER_HOME="${HOME-}"
export HOME="${MAIN_DIR:?}"
export HOME="${MAIN_DIR}"
fi

fi
Expand Down Expand Up @@ -59,9 +59,9 @@ if test "${A5K_FUNCTIONS_INCLUDED:-false}" = 'false'; then
__SHELL_EXE="$(get_shell_exe)" || __SHELL_EXE='bash'
export __SHELL_EXE

_shell_info_line="$("${__SHELL_EXE:?}" 2>&1 --help | head -n 1 || :)"
_shell_info_line="$("${__SHELL_EXE}" 2>&1 --help | head -n 1 || :)"
_is_busybox='false'
case "${_shell_info_line?}" in
case "${_shell_info_line}" in
*'BusyBox'*) _is_busybox='true' ;;
*) ;;
esac
Expand All @@ -71,14 +71,14 @@ if test "${A5K_FUNCTIONS_INCLUDED:-false}" = 'false'; then
unset IS_PATH_INITIALIZED
unset __QUOTED_PARAMS

if test -n "${MAIN_DIR-}"; then _main_dir="${MAIN_DIR:?}"; else _main_dir='.'; fi
if test -n "${MAIN_DIR-}"; then _main_dir="${MAIN_DIR}"; else _main_dir='.'; fi

if test "${_is_busybox:?}" = 'true'; then
ash -s -c ". '${_main_dir:?}/includes/common.sh' || exit \${?}" 'ash' "${@}"
if test "${_is_busybox}" = 'true'; then
exec ash -s -c ". '${_main_dir}/includes/common.sh' || exit \${?}" 'ash' "${@}"
else
if test "${#}" -gt 0; then
case "${*}" in
*"${_newline:?}"*)
*"${_newline}"*)
printf 'WARNING: Newline character found, parameters dropped\n'
;;
*)
Expand All @@ -88,7 +88,7 @@ if test "${A5K_FUNCTIONS_INCLUDED:-false}" = 'false'; then
esac
fi

exec "${__SHELL_EXE:?}" --init-file "${_main_dir:?}/includes/common.sh"
exec "${__SHELL_EXE}" --init-file "${_main_dir}/includes/common.sh"
fi
}

Expand Down
10 changes: 3 additions & 7 deletions includes/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1026,17 +1026,13 @@ sume()
fi
! is_root || return 0

if test "${PLATFORM:?}" = 'win'; then
_set_env_vars="export HOME='${HOME-}'; export USER_HOME='${USER_HOME-}'; export MAIN_DIR='${MAIN_DIR:?}';"
fi
_set_env_vars="export HOME='${HOME-}'; export USER_HOME='${USER_HOME-}'; export MAIN_DIR='${MAIN_DIR:?}';"

if test "${IS_BUSYBOX:?}" = 'true'; then
# shellcheck disable=SC2016 # Ignore: Expressions don't expand in single quotes
su -c "${_set_env_vars?} ${MAIN_DIR:?}"'/cmdline.sh "${@}"' -- root "${0-}" "${@}"
su -c "${_set_env_vars} . '${MAIN_DIR:?}/cmdline.sh' \"\${@}\"" -- root "${0-}" "${@}"
elif test -n "${BB_CMD?}" && test -n "${SHELL_EXE?}"; then
_fix_pwd="cd '${PWD:?}';"
# shellcheck disable=SC2016 # Ignore: Expressions don't expand in single quotes
"${BB_CMD:?}" su -s "${SHELL_EXE:?}" -c "${_set_env_vars?} ${_fix_pwd?} ${MAIN_DIR:?}"'/cmdline.sh "${@}"' -- root "${0-}" "${@}"
"${BB_CMD:?}" su -s "${SHELL_EXE:?}" -c "${_set_env_vars} ${_fix_pwd} . '${MAIN_DIR:?}/cmdline.sh' \"\${@}\"" -- root "${0-}" "${@}"
else
ui_warning 'sume failed!!!'
return 125
Expand Down

0 comments on commit 355e407

Please sign in to comment.