bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposed BASH_SOURCE_PATH


From: konsolebox
Subject: Re: proposed BASH_SOURCE_PATH
Date: Thu, 20 Jun 2024 05:31:15 +0800

On Thu, Jun 20, 2024 at 4:47 AM Léa Gris <lea.gris@noiraude.net> wrote:
> realSource=$(realpath -- "${BASH_SOURCE[0]}") &&
> realScriptDir=${realSource%/*}

`realScriptDir=$(realpath -m "${BASH_SOURCE}/..") || exit` is simpler
if you don't care about versions of realpath not supporting `-m`.

It is mostly convenient if you only need to load a single script.  For example:

source "$(realpath -m "${BASH_SOURCE}/../../lib/script.bash")" || exit


-- 
konsolebox



reply via email to

[Prev in Thread] Current Thread [Next in Thread]