[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: small problem with BASH_SOURCE and PATH
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: small problem with BASH_SOURCE and PATH |
Date: |
Fri, 11 Feb 2022 19:55:48 +0100 |
function absolutebasepath() {
declare arg t=
for arg; do
if [[ ${t:=$arg} != /* ]]; then
if [[ $t == */* ]]; then
r=$PWD/${t%/*}; else
r=$PWD/.; fi; else
r=${t%/*}; fi
absolutebasepath+=( "$r" )
done
}
i post this in hopes for others
it returns ( in an array ) its args as aboslute base paths
useful for 'where script is'
absolutebasepath "$BASH_SOURCE"
printf 'script is in %s\n' "$absolutebasepath"
( multiple runs multiple elements )
${absolutebasepath[0]} is default and if ran multiple then [1] [2] etc
ill hopefully code an assignments only variant and post it, maybe with
benchmarks
- Re: Re: small problem with BASH_SOURCE and PATH, (continued)
Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/10
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/10
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Greg Wooledge, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH,
Alex fxmbsw7 Ratchev <=
- Re: small problem with BASH_SOURCE and PATH, Dennis Williamson, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Greg Wooledge, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Greg Wooledge, 2022/02/11
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/12
- Re: small problem with BASH_SOURCE and PATH, Greg Wooledge, 2022/02/12
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/12