save and reuse original argv when auto-elevating

Fixes FS#42277.
This commit is contained in:
Dave Reisner 2014-10-19 16:06:31 -04:00
parent cae954ddb5
commit bf7dc83bab
4 changed files with 14 additions and 6 deletions

View File

@ -26,6 +26,8 @@ usage() {
exit 1
}
orig_argv=("$@")
while getopts 'hC:M:c:' arg; do
case "$arg" in
C) pac_conf="$OPTARG" ;;
@ -38,7 +40,7 @@ done
shift $(($OPTIND - 1))
(( $# < 1 )) && die 'You must specify a directory.'
check_root "$0" "$@"
check_root "$0" "${orig_argv[@]}"
working_dir=$(readlink -f "$1")
shift 1

View File

@ -29,6 +29,8 @@ usage() {
exit 1
}
orig_argv=("$@")
while getopts 'hcr:' arg; do
case "${arg}" in
c) clean_first=true ;;
@ -37,11 +39,11 @@ while getopts 'hcr:' arg; do
esac
done
check_root "$0" "${orig_argv[@]}"
# Pass all arguments after -- right to makepkg
makechrootpkg_args+=("${@:$OPTIND}")
check_root "$0" "$@"
if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
msg "Creating chroot for [${repo}] (${arch})..."

View File

@ -66,6 +66,8 @@ usage() {
exit 1
}
orig_argv=("$@")
while getopts 'hcur:I:l:nTD:d:' arg; do
case "$arg" in
h) usage ;;
@ -81,10 +83,10 @@ while getopts 'hcur:I:l:nTD:d:' arg; do
esac
done
check_root "$0" "$@"
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
check_root "$0" "${orig_argv[@]}"
# Canonicalize chrootdir, getting rid of trailing /
chrootdir=$(readlink -e "$passeddir")
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"

View File

@ -24,6 +24,8 @@ usage() {
exit 1
}
orig_argv=("$@")
while getopts 'hC:M:c:' arg; do
case "$arg" in
C) pac_conf="$OPTARG" ;;
@ -37,7 +39,7 @@ shift $(($OPTIND - 1))
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
check_root "$0" "$@"
check_root "$0" "${orig_argv[@]}"
working_dir="$(readlink -f $1)"
shift 1