diff --git a/lib-core.sh b/lib-core.sh index 4c30443..016b8bc 100755 --- a/lib-core.sh +++ b/lib-core.sh @@ -21,7 +21,7 @@ WHITESUR_SOURCE=("lib-core.sh") #--------------System--------------# export WHITESUR_PID=$$ -MY_USERNAME="$(logname || echo ${SUDO_USER:-${USER}})" +MY_USERNAME="$(logname 2> /dev/null || echo ${SUDO_USER:-${USER}})" if command -v gnome-shell &> /dev/null; then if (( $(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f 1) >= 4 )); then @@ -629,13 +629,11 @@ sudo() { fi if [[ -p /dev/stdin ]]; then - ${SUDO_BIN} "${@}" < /dev/stdin + ${SUDO_BIN} "${@}" < /dev/stdin || result="${?}" else - ${SUDO_BIN} "${@}" + ${SUDO_BIN} "${@}" || result="${?}" fi - result="${?}" - [[ "${result}" != "0" ]] && WHITESUR_COMMAND="${*}" return "${result}" @@ -651,13 +649,11 @@ udo() { fi if [[ -p /dev/stdin ]]; then - ${SUDO_BIN} -u "${MY_USERNAME}" "${@}" < /dev/stdin + ${SUDO_BIN} -u "${MY_USERNAME}" "${@}" < /dev/stdin || result="${?}" else - ${SUDO_BIN} -u "${MY_USERNAME}" "${@}" + ${SUDO_BIN} -u "${MY_USERNAME}" "${@}" || result="${?}" fi - result="${?}" - [[ "${result}" != "0" ]] && WHITESUR_COMMAND="${*}" return "${result}" diff --git a/lib-install.sh b/lib-install.sh index a09ed99..b11ec83 100755 --- a/lib-install.sh +++ b/lib-install.sh @@ -112,9 +112,11 @@ install_swupd_packages() { } prepare_install_apt_packages() { - sudo apt update -y; sudo apt install -y "${@}" + local status="1" - if [[ "${?}" == "100" ]]; then + sudo apt update -y; sudo apt install -y "${@}" || status="${?}" + + if [[ "${status}" == "100" ]]; then prompt -w "\n APT: Your repo lists might be broken" prompt -i "APT: Full-cleaning your repo lists and try again...\n" sudo apt clean -y; sudo rm -rf /var/lib/apt/lists