[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: |
Sat, 12 Feb 2022 08:59:12 +0100 |
On Fri, Feb 11, 2022 at 11:42 PM Greg Wooledge <greg@wooledge.org> wrote:
> On Fri, Feb 11, 2022 at 11:10:06PM +0100, Alex fxmbsw7 Ratchev wrote:
> > On Fri, Feb 11, 2022 at 11:02 PM Greg Wooledge <greg@wooledge.org>
> wrote:
> >
> > > On Fri, Feb 11, 2022 at 10:24:46PM +0100, Alex fxmbsw7 Ratchev wrote:
> > > > >> http://mywiki.wooledge.org/BashFAQ/028
> > > > >>
> > > > >
> > > > > err from the page
> > > > >
> > > >
> > > > greg, consider overhaulting your whole page, or it gets marked as
> invalid
> > > > as the others by me
> > >
> > > It's a wiki. It's publically writable. Most of the pages on the wiki
> > > have multiple contributors.
> > >
> > > > > bash stup ; cat stup
> > > > > stup: line 1: cd: stup/: Not a directory
> > > > > /root
> > > > > cd "${BASH_SOURCE%/*}/"
> > > > > pwd
> > >
> > > Haven't we already covered this? You're using BASH_SOURCE and assuming
> > > what will be in it conforms to a certain pattern. And then you're
> calling
> > > the script with "bash stup" which means the content of BASH_SOURCE does
> > > *not* match the pattern you expected it to match. It contains "stup"
> > > rather than "./stup".
> > >
> > yea its from your page tho, u didnt cover the noslashinside case
>
> It was Lhunath who introduced virtually(?) all of the BASH_SOURCE
> content on this page. First with a "comment" back in 2011:
>
> https://mywiki.wooledge.org/BashFAQ/028?action=diff&rev2=16&rev1=15
>
> Then a series of edits in 2013 which rewrote much of the page:
>
> https://mywiki.wooledge.org/BashFAQ/028?action=diff&rev2=26&rev1=22
>
> Then some more edits, still in 2013, which introduced the code you're
> using:
>
> https://mywiki.wooledge.org/BashFAQ/028?action=diff&rev2=31&rev1=29
>
> Clearly Lhunath intended this code to be used only when running the
> script as a command, e.g. "myscript", not by typing "bash myscript".
> If you'd like to edit the page to make that clear, go ahead. As I
> said, it's a publically writable wiki.
>
correction, its made when "./script" or "bash ./script"
if its not the slash to remove is missing and the case isnt covered by if
so it fails
i dunno to edit it maybe i can somewhen later but i dont think ill have
much success
> Nobody else has run into this problem in the 8 years since Lhunath
> made that edit, or at least they haven't brought it to my attention.
> Your usage cases are fairly unique.
>
i suppose nobody told you.. the code doesnt magically get to work :))
- Re: small problem with BASH_SOURCE and PATH, (continued)
- 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
- 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, Greg Wooledge, 2022/02/12
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/12
- Re: small problem with BASH_SOURCE and PATH, Alex fxmbsw7 Ratchev, 2022/02/12