[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 18:43:18 +0100 |
On Fri, Feb 11, 2022 at 5:52 PM Greg Wooledge <greg@wooledge.org> wrote:
> On Fri, Feb 11, 2022 at 01:57:51PM +0100, Alex fxmbsw7 Ratchev wrote:
> > i think this is a bash bug issue
> >
> > when i type -p randurl.gawk first it works
>
> What does it *say*?
>
i didnt watch, i just error checked it for exec printf err
>
> > so i suppose a hash -r should do
>
> Why would removing a hash entry in your interactive shell affect the PATH
> used by a script?
>
i think it was as u explain later not an absolute path indeed
> > On Thu, Feb 10, 2022 at 11:36 PM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com
> >
> > wrote:
> > >
> > > my=/tmp/$SRANDOM ; mkdir -p $my/bin ; cd $my ; printf 'yes | head -3'
> > >bin/ye ; printf >script %s\\n '#!/usr/bin/env -S
> > > bash' 'PATH=$PATH:${BASH_SOURCE%/*}/bin' 'ye' ; chmod +x * */* ; bash
> > script ; ./script
> > > script: line 3: ye: command not found
> > > y
> > > y
> > > y
>
> Basically you are assuming that BASH_SOURCE contains something useful
> enough to incorporate into the PATH variable during the execution of
> a script. And despite getting this error message, you have not even
> attempted to look at the values of BASH_SOURCE or PATH to determine
> what's actually happened.
>
indeed i did not, i was and am tired
this is some specific psychic issue with this issue with debugging, when
having headpain.. ah well i hoped for good and there u mailed
btw its ./script and ./bin/ so where script is its bin/ dir ( supposently )
unicorn:~$ printf '%s\n' >foo '#!/bin/bash' 'declare -p BASH_SOURCE'; chmod
> +x foo
> unicorn:~$ ./foo
> declare -a BASH_SOURCE=([0]="./foo")
> unicorn:~$ bash foo
> declare -a BASH_SOURCE=([0]="foo")
>
> As you can see, the value of BASH_SOURCE changes depending on how you
> invoke the script.
>
> Consider what happens when you perform ${BASH_SOURCE%/*} on each of these
> values. And then what happens when you put the results into PATH.
>
i remember having this solution, when a path didnt have beginning slash
then prepend $PWD/ to it
i just forgot completly about it, gotta code it in, either this or realpath
i better not touch realpath for portability
- 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/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 <=
- 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, 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