bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warn upon "declare -ax"


From: Andreas Kähäri
Subject: Re: Warn upon "declare -ax"
Date: Tue, 5 Sep 2023 17:09:52 +0200

On Tue, Sep 05, 2023 at 04:04:50PM +0200, alex xmb ratchev wrote:
> On Mon, Sep 4, 2023, 15:19 Kerin Millar <kfm@plushkava.net> wrote:
> 
> > On Mon, 4 Sep 2023 14:46:08 +0200
> > Léa Gris <lea.gris@noiraude.net> wrote:
> >
> > > Le 04/09/2023 à 14:18, Dan Jacobson écrivait :
> > > > Shouldn't "declare -ax" print a warning that it is useless?
> > >
> > > There don's seem to be any warning system in Bash or other shells. As
> > > long as it is not a fatal error condition and errexit is not set,
> > > execution continue.
> > >
> > > There are static analysis tools like Shellcheck which might be expanded
> > > to ware of such incompatible flags but that's it.
> >
> > Curiously, ARRAY_EXPORT can be defined in config-top.h. It's probably safe
> > to say that nobody uses it (nor should anybody wish to upon realising how
> > it works).
> >
> 
> does it make too big copies or wha ..
> 
> greets , peace ..
> 

On Unix systems, environment variables are plain key-value pairs of
strings.  An array in bash is not a key-value pair of strings, but
a list of strings (and corresponding indexes).  The ARRAY_EXPORT
configuration option (which I believe isn't settable from the
"configure" script, and which I've never tried enabling) presumably
makes arrays exportable somehow (probably only to other bash shell
instances, similar to how "exportable functions" work).  However, since
this is not generally supported, and definitely not supported by the
default configuration of bash, using this feature makes your scripts
hopelessly non-portable.  That's part of the "or wha".  I haven't looked
at the implementation, so Kerin's view may be more informed than mine.


-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]