[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: small problem with BASH_SOURCE and PATH
From: |
Greg Wooledge |
Subject: |
Re: small problem with BASH_SOURCE and PATH |
Date: |
Sat, 12 Feb 2022 08:47:19 -0500 |
On Sat, Feb 12, 2022 at 08:59:12AM +0100, Alex fxmbsw7 Ratchev wrote:
> On Fri, Feb 11, 2022 at 11:42 PM Greg Wooledge <greg@wooledge.org> wrote:
> > 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
Incorrect.
unicorn:~$ vi bin/xmb
unicorn:~$ chmod +x bin/xmb
unicorn:~$ cat bin/xmb
#!/bin/bash
declare -p BASH_SOURCE
unicorn:~$ xmb
declare -a BASH_SOURCE=([0]="/home/greg/bin/xmb")
When invoked as a command through the shebang mechanism, you get a
path with slashes in it. The *only* time it fails is when you explicitly
type "bash scriptname".
It would be nice if you would take 2 minutes to test these things
yourself, rather than spouting ignorance.
- 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, 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, 2022/02/12
- Re: small problem with BASH_SOURCE and PATH,
Greg Wooledge <=
- 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