Don't rely on $0 to determine script names.
Programs can freely define the value of argv0 and thus it means nothing. Instead, use the bash-specific variable explicitly designed to safely and accurately reference the name of the currently sourced file. This also fixes the case where simple debugging mechanisms like using "bash -x foo" tried to treat "foo" as the unqualified $0 and therefore broke horribly due to lack of pathnames. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
parent
e76d560477
commit
8f5a02b23d
|
@ -13,7 +13,7 @@ if [[ $1 = "--ignore-internal" ]]; then
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
script_mode=${0##*/find-lib}
|
script_mode=${BASH_SOURCE[0]##*/find-lib}
|
||||||
|
|
||||||
case $script_mode in
|
case $script_mode in
|
||||||
deps|provides) true;;
|
deps|provides) true;;
|
||||||
|
|
|
@ -8,7 +8,7 @@ CHROOT_VERSION='v4'
|
||||||
##
|
##
|
||||||
# usage : check_root $keepenv
|
# usage : check_root $keepenv
|
||||||
##
|
##
|
||||||
orig_argv=("$0" "$@")
|
orig_argv=("${BASH_SOURCE[0]}" "$@")
|
||||||
check_root() {
|
check_root() {
|
||||||
local keepenv=$1
|
local keepenv=$1
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# This script rebuilds a list of packages in order
|
# This script rebuilds a list of packages in order
|
||||||
# and reports anything that fails
|
# and reports anything that fails
|
||||||
#
|
#
|
||||||
# Due to sudo usage, it is recommended to allow makechrootpkg
|
# Due to sudo usage, it is recommended to allow makechrootpkg
|
||||||
# to be run with NOPASSWD in your sudoers file
|
# to be run with NOPASSWD in your sudoers file
|
||||||
#
|
#
|
||||||
|
@ -14,8 +14,8 @@
|
||||||
m4_include(lib/common.sh)
|
m4_include(lib/common.sh)
|
||||||
|
|
||||||
if (( $# < 1 )); then
|
if (( $# < 1 )); then
|
||||||
printf 'Usage: %s <chrootdir> <packages to rebuild>\n' "$(basename "$0")"
|
printf 'Usage: %s <chrootdir> <packages to rebuild>\n' "$(basename "${BASH_SOURCE[0]}")"
|
||||||
printf ' example: %s ~/chroot readline bash foo bar baz\n' "$(basename "$0")"
|
printf ' example: %s ~/chroot readline bash foo bar baz\n' "$(basename "${BASH_SOURCE[0]}")"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue