diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-03-30 05:07:36 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-04-06 12:29:43 +0200 |
commit | 6199e368f68dcc9faabb48277c9d014ea0a4f0db (patch) | |
tree | 871f0159f72876adea0f8e45f3e181e3078b7742 | |
parent | 051fd93351848c3aaee158a6d84ba4af1beb584c (diff) | |
download | mbuto-6199e368f68dcc9faabb48277c9d014ea0a4f0db.tar mbuto-6199e368f68dcc9faabb48277c9d014ea0a4f0db.tar.gz mbuto-6199e368f68dcc9faabb48277c9d014ea0a4f0db.tar.bz2 mbuto-6199e368f68dcc9faabb48277c9d014ea0a4f0db.tar.lz mbuto-6199e368f68dcc9faabb48277c9d014ea0a4f0db.tar.xz mbuto-6199e368f68dcc9faabb48277c9d014ea0a4f0db.tar.zst mbuto-6199e368f68dcc9faabb48277c9d014ea0a4f0db.zip |
mbuto: Parse options before fakeroot check
...so that we can display the help message even if fakeroot is not
available.
Suggested-by: Wainer dos Santos Moschetta <wmoschet@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rwxr-xr-x | mbuto | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -916,14 +916,7 @@ usage() { ################################################################################ -# Entry point: if we're not running as root, re-run with fakeroot -if [ "${LD_PRELOAD}" != "libfakeroot-sysv.so" ] && [ "$(id -u)" -ne 0 ]; then - if ! FAKEROOT="$(command -v fakeroot)"; then - err "Not root and no fakeroot available, exiting" - fi - PATH="${PATH}:/sbin:/usr/sbin" "${FAKEROOT}" "${0}" "$@" - exit ${?} -fi +ARGS=${@} # Parse options while getopts c:df:k:m:p:s:vh __opt; do @@ -940,9 +933,17 @@ while getopts c:df:k:m:p:s:vh __opt; do esac done shift $((OPTIND - 1)) - [ -z "${PROFILE}" ] && PROFILE="base" +# If we're not running as root, re-run with fakeroot +if [ "${LD_PRELOAD}" != "libfakeroot-sysv.so" ] && [ "$(id -u)" -ne 0 ]; then + if ! FAKEROOT="$(command -v fakeroot)"; then + err "Not root and no fakeroot available, exiting" + fi + PATH="${PATH}:/sbin:/usr/sbin" "${FAKEROOT}" "${0}" ${ARGS} + exit ${?} +fi + # Check needed tools, exit if any is missing for __l in ${TOOLS}; do cmd_check "${__l}" |