Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-20 Thread Zachary Santer
On Tue, Feb 20, 2024 at 2:38 PM alex xmb sw ratchev wrote: > check if $BASH_SOURCE begins with a / , else prepend $PWD to it > to path of file > source "$( dirname -- "$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" )\ /common/sourced-file.bash" What I do, anyway. Won't let symlin

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-20 Thread alex xmb sw ratchev
On Tue, Feb 20, 2024, 17:53 Zachary Santer wrote: > On Tue, Feb 20, 2024 at 11:17 AM Chet Ramey wrote: > > > > > BASH_SOURCE and BASH_LINENO are part of the debugger support, and exist > so > > the debugger can create a function call stack. > > > > I've definitely used them to create my own call

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-20 Thread Chet Ramey
On 2/17/24 6:47 PM, Zachary Santer wrote: If you're satisfied with $_ or now $0, then fine, but I would actually expect that to show up as ${BASH_SOURCE[1]} within the ${BASH_ENV} script, which it obviously doesn't. Don't know what ${BASH_LINENO[0]} ought to be in that case. Maybe 0? The way th

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-20 Thread Zachary Santer
On Tue, Feb 20, 2024 at 11:17 AM Chet Ramey wrote: > > BASH_SOURCE and BASH_LINENO are part of the debugger support, and exist so > the debugger can create a function call stack. > > I've definitely used them to create my own call stack. I've seen ${BASH_SOURCE[0]} given as preferable to ${0} for

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-17 Thread Marc Aurèle La France
On Sat, 2024-Feb-17, Zachary Santer wrote: On Sat, Feb 17, 2024, Marc Aurèle La France wrote: Do ... rm -fr GREPME grepme echo '#! /bin/bash\nset' > GREPME "ln" GREPME grepme chmod a+x grepme ... then (case matters) ... BASH_ENV=GREPME ./grepme | fgrep -iw grepme ... gives ... B

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-17 Thread Zachary Santer
On Sat, Feb 17, 2024 at 3:44 PM Marc Aurèle La France wrote: > Do ... > > rm -fr GREPME grepme > echo '#! /bin/bash\nset' > GREPME > "ln" GREPME grepme > chmod a+x grepme > > ... then (case matters) ... > > BASH_ENV=GREPME ./grepme | fgrep -iw grepme > > ... gives ... > > BASH_ARGV=([0]="GREPME")

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-17 Thread Marc Aurèle La France
On Fri, 2024-Feb-16, Grisha Levit wrote: On Fri, Feb 16, 2024, Marc Aurèle La France wrote: On Mon, 2021-Feb-01, Marc Aurèle La France wrote: Currently, only the script's arguments are passed as positional parameters. For compatibility reasons, $0 cannot be used to also pass the script's fil

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-17 Thread Marc Aurèle La France
On Sat, 2024-Feb-17, Zachary Santer wrote: On Fri, Feb 16, 2024, Marc Aurèle La France wrote: On Fri, 2024-Feb-16, Zachary Santer wrote: And you're sure ${BASH_SOURCE[0]} wasn't what you wanted all along? Yes, but that doesn't matter now. At the bottom of my .bashrc file: printf '%s\n'

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-17 Thread Zachary Santer
On Fri, Feb 16, 2024 at 9:45 PM Marc Aurèle La France wrote: > On Fri, 2024-Feb-16, Zachary Santer wrote: > > > And you're sure ${BASH_SOURCE[0]} wasn't what you wanted all along? > > Yes, but that doesn't matter now. > At the bottom of my .bashrc file: printf '%s\n' "Hello, this script is ${BAS

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-16 Thread Grisha Levit
On Fri, Feb 16, 2024, 16:17 Marc Aurèle La France wrote: > > On Mon, 2021-Feb-01, Marc Aurèle La France wrote: > > > Currently, only the script's arguments are passed as positional > > parameters. For compatibility reasons, $0 cannot be used to also pass the > > script's filename, so I'm creating

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-16 Thread Marc Aurèle La France
On Fri, 2024-Feb-16, Zachary Santer wrote: On Fri, Feb 16, 2024, Marc Aurèle La France wrote: On Mon, 2021-Feb-01, Marc Aurèle La France wrote: Currently, only the script's arguments are passed as positional parameters. For compatibility reasons, $0 cannot be used to also pass the script's f

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-16 Thread Zachary Santer
On Fri, Feb 16, 2024 at 4:17 PM Marc Aurèle La France wrote: > On Mon, 2021-Feb-01, Marc Aurèle La France wrote: > > > Currently, only the script's arguments are passed as positional > > parameters. For compatibility reasons, $0 cannot be used to also pass > the > > script's filename, so I'm cre

Re: Bash 5.1: Make shell_script_filename available to startup files

2024-02-16 Thread Marc Aurèle La France
On Mon, 2021-Feb-01, Marc Aurèle La France wrote: Currently, only the script's arguments are passed as positional parameters. For compatibility reasons, $0 cannot be used to also pass the script's filename, so I'm creating a new BASH_SCRIPT variable instead. --- bash-5.1/doc/bash.1 +++ devel

Re: Bash 5.1: Make shell_script_filename available to startup files

2021-02-08 Thread Chet Ramey
On 2/8/21 10:04 AM, Marc Aurèle La France wrote: Yes, I could have all such scripts source a file when they start.  But isn't that just another startup file?  And duplication.  Or pass something through $1;  again duplication.  BASH_SCRIPT is a more elegant solution and doesn't require any int

Re: Bash 5.1: Make shell_script_filename available to startup files

2021-02-08 Thread Marc Aurèle La France
On Tue, 2 Feb 2021, Marc Aurèle La France wrote: On Tue, 2 Feb 2021, Chet Ramey wrote: On Mon, 1 Feb 2021, Marc Aurèle La France wrote: Currently, only the script's arguments are passed as positional parameters. For compatibility reasons, $0 cannot be used to also pass the script's filename,

Re: Bash 5.1: Make shell_script_filename available to startup files

2021-02-02 Thread Marc Aurèle La France
On Tue, 2 Feb 2021, Chet Ramey wrote: On Mon, 1 Feb 2021, Marc Aurèle La France wrote: Currently, only the script's arguments are passed as positional parameters. For compatibility reasons, $0 cannot be used to also pass the script's filename, so I'm creating a new BASH_SCRIPT variable instea

Re: Bash 5.1: Make shell_script_filename available to startup files

2021-02-02 Thread Chet Ramey
On 2/1/21 6:17 PM, Marc Aurèle La France wrote: Currently, only the script's arguments are passed as positional parameters. For compatibility reasons, $0 cannot be used to also pass the script's filename, so I'm creating a new BASH_SCRIPT variable instead. I'm interested in use cases for this