From 8f5a02b23ddb2491c13553cb71276bdd088f63ac Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 13 Feb 2019 01:32:03 -0500 Subject: 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 Signed-off-by: Levente Polyak --- lib/archroot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/archroot.sh b/lib/archroot.sh index 06d4519..8f063cd 100644 --- a/lib/archroot.sh +++ b/lib/archroot.sh @@ -8,7 +8,7 @@ CHROOT_VERSION='v4' ## # usage : check_root $keepenv ## -orig_argv=("$0" "$@") +orig_argv=("${BASH_SOURCE[0]}" "$@") check_root() { local keepenv=$1 -- cgit v1.2.3-70-g09d2