[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using a variable from global scope or checking whether it is local t
From: |
ikhxcsz7y xmbott |
Subject: |
Re: using a variable from global scope or checking whether it is local to some scope |
Date: |
Fri, 20 Oct 2023 00:01:47 +0200 |
On Thu, Oct 19, 2023, 23:42 Christoph Anton Mitterer <calestyo@scientia.org>
wrote:
> Hey Alex.
>
> On Thu, 2023-10-19 at 22:17 +0200, alex xmb sw ratchev wrote:
> > another answer
> > in ur code , force global / local whenever u need it
> >
> > ~ $ ( declare -g a ; a=2 ; declare -p a ; declare a ; declare -p a ;
> > a=3 )
> > declare -- a="2"
> > declare -- a="2"
> > ~ $
> >
> > sadly i didnt find difference there
> > but just declare -g or non -g when u need
>
> I don't understand how this should help?
> Yes it allows me to set the global one, but I cannot expand it?
>
checking if not global or local is nonsense
its like u set a=2 and check $a == 2
i mean , u , the coder , makes the codeflow , .. , i can only imagine it
useful in insert code at deep places , eg hack bashs system memory
and .. i am _for_ a if local check .. its just bash lacks many , so im used
to fail
greets
a=global
>
> other()
> {
> local a=from_other
> mine
> echo $a
> }
>
> mine()
> {
> echo $a
> ( declare -g a ; echo $a; declare -p a )
>
> }
>
> echo $a
> other
>
>
> gives:
> global
> from_other
> from_other
> declare -- a="from_other"
> from_other
>
>
>
> Cheers,
> Chris.
>
>