[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proposed BASH_SOURCE_PATH
From: |
Greg Wooledge |
Subject: |
Re: proposed BASH_SOURCE_PATH |
Date: |
Thu, 16 May 2024 00:09:45 -0400 |
On Thu, May 16, 2024 at 10:51:01AM +0700, Robert Elz wrote:
> Personally, I don't think there is anything common here at all, most
> scripts don't fetch bits from other places, everything simply goes in
> the script, and the need for the '.' command at run time is avoided.
>
> In general, I suspect that almost all use of '.' is for people writing
> a bunch of scripts for personal use, which use a set of common functions
> that that suit the needs of the person writing the script
There is one extremely noteworthy example of '.' being used in production
shell scripts: System V rc scripts on Linux systems.
As just one example, the /etc/init.d/cron script shipped with Debian's
cron package dots in /lib/lsb/init-functions very early. This model
of "helper functions commonly used by a bunch of related scripts" is
prevalent in many Linux distributions' sysv-rc scripts, where such
scripts still exist at all.
This same script also contains the following line:
[ -r /etc/default/cron ] && . /etc/default/cron
This is another common practice in Linux sysv-rc scripts. The files in
/etc/default/ are dottable shell fragments used to set configuration
variables. They're intended to be user editable.
You'll note that both of the files being dotted in by this script are
absolute pathnames. I am not aware of *any* scripts that use relative
paths and the $PATH variable to search for files to be dotted in. I
can't say *nobody* does it, but I don't recall seeing it.
- Re: proposed BASH_SOURCE_PATH, (continued)
- Re: proposed BASH_SOURCE_PATH, Léa Gris, 2024/05/14
- Re: proposed BASH_SOURCE_PATH, Chet Ramey, 2024/05/15
- Re: proposed BASH_SOURCE_PATH, Koichi Murase, 2024/05/15
- Re: proposed BASH_SOURCE_PATH, Chet Ramey, 2024/05/15
- Re: proposed BASH_SOURCE_PATH, Robert Elz, 2024/05/15
- Re: proposed BASH_SOURCE_PATH,
Greg Wooledge <=
- Re: proposed BASH_SOURCE_PATH, Matheus Afonso Martins Moreira, 2024/05/14